Patch Detail
Show a patch.
GET /api/1.1/patches/16762/?format=api
{ "id": 16762, "url": "https://patchwork.libcamera.org/api/1.1/patches/16762/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16762/", "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": "<20220725134639.4572-8-naush@raspberrypi.com>", "date": "2022-07-25T13:46:31", "name": "[libcamera-devel,07/15] DNI: ipa: raspberrypi: Code refactoring to match style guidelines", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "4e6972dfc5de11d3f6d4c7004d0e767abd2087f4", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16762/mbox/", "series": [ { "id": 3323, "url": "https://patchwork.libcamera.org/api/1.1/series/3323/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3323", "date": "2022-07-25T13:46:24", "name": "Raspberry Pi IPA code refactor", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3323/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16762/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16762/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 DEF8EC3275\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 25 Jul 2022 13:46:58 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 969A163332;\n\tMon, 25 Jul 2022 15:46:58 +0200 (CEST)", "from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com\n\t[IPv6:2a00:1450:4864:20::42f])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F3F0C6331B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 25 Jul 2022 15:46:50 +0200 (CEST)", "by mail-wr1-x42f.google.com with SMTP id d8so15975791wrp.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 25 Jul 2022 06:46:50 -0700 (PDT)", "from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\ta20-20020a05600c225400b003a32167b8d4sm18054320wmm.13.2022.07.25.06.46.47\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 25 Jul 2022 06:46:48 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658756818;\n\tbh=3uw8DoPxbGZnW/F+l1CPOUcCMu6i2Y+wYaFB0GdDYR4=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=BjKudKo/UxCOrXS1/XyCclMh2O/2P1rJJFXje7lDxeIf5z5U6YCT7FLIhpy/taos9\n\thrSB1HV8d4huSTAPodN0ZhSjBCBX9Md0G5uwYB/CpiB8BD795WRgYsWWswT58SA+Za\n\tCqba0wqL7h5g0sZRNriSlFiVdLfiWBM7d+4bwqMlV3QmwWsdizjIjZtm9iRhJKndMK\n\t1nXzG8z2K3pZkm1n6Wb9cueOJj/L+yar0tnzP4jXhRQ9r57Q3Y2D7CYg+mSCCPtTod\n\t9yuqhkwV5vXKHbPWxonw8f0uWYs5L9LoHt1EPzX6Haj61gIM3CnjFlTLYFUHVmNnwU\n\tJASxwuKgNM4yA==", "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=PGJdRK/xNV9iwHqwQgGYKaCxqkV/boqeD/D9atBkvEQ=;\n\tb=AWY8SvgP/51I7GHIvMHtIrmZDE/46aPbowZ/JcQmy9iZnY9PN9rztWVlplTEdzOffd\n\tQLTZGxwpridfcNag5IHvWGpe7X5+1SnOyCfdS89Ul4zJ/o1qanyN3ua4jEKUU4Ls+thY\n\tMZE2NuKAq2f9xZdyEnPMP5mNLabGiLLPlKR9coyqTHEtJ1wL3nFso+w0HIWDjxu3QTQm\n\tJcX6C1a65fHYc6bsHRE081RKisEsQ/kLjhvcTbxJ5NO10Pd1OdApKx9Xd10Nl7qWUP3f\n\t9A+Q7mthu0i5fGqbyC3eG6UvakJeb02tF6R2gkQP9IYJV0k7RJvYDfF2QpvCUlEEjp4U\n\tbUBw==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"AWY8SvgP\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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=PGJdRK/xNV9iwHqwQgGYKaCxqkV/boqeD/D9atBkvEQ=;\n\tb=H7HnXPiq8KnvuG1Lb91mMinnMUNHjc59r2LLEC8CDLk51y8xsQ7cBSf/aODebIfnHF\n\t+kgLoMIryLPrPi9DtljZI/klpttkk8ZyWMyxgLEstAFg3wljY7Y3p2E7Wgjk/SNzp/r8\n\tXqpBxD5PWD1Cb/y+dLVuPjoEu3RZG+xJwz84TkuWIKadaEgPHN9LgnqbkA5rIiHhhFGL\n\teH/uZxQlqqDsBF03JosFXu+gJ3/9qVqkY0ORGxCkctAJsvSZzu8+5dVw8XipqvqjGgro\n\tlG8NJWskG+hIrRF4hictD3+0fMYkXtot8XKCxJuSAMKaCFOL02wOh/ZjRxYfkEoMO0hJ\n\tQSsw==", "X-Gm-Message-State": "AJIora9o9/TnqaakDN29f+FNOhdq6nz/Tp5FejpHhFWTVlXQr10UZChW\n\tgk9Wt2fJMIdxWjpYiL/Vrqeat7UP9rg/0A==", "X-Google-Smtp-Source": "AGRyM1uNx75F0hHWNS1mGwPdncnz0DSgJ+JVoz97WfcATskjixT42XznbGtdUCSwl6Ju1PWYECqYBg==", "X-Received": "by 2002:a05:6000:719:b0:21e:4530:c558 with SMTP id\n\tbs25-20020a056000071900b0021e4530c558mr7398021wrb.243.1658756808599; \n\tMon, 25 Jul 2022 06:46:48 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 25 Jul 2022 14:46:31 +0100", "Message-Id": "<20220725134639.4572-8-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20220725134639.4572-1-naush@raspberrypi.com>", "References": "<20220725134639.4572-1-naush@raspberrypi.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 07/15] DNI: ipa: raspberrypi: Code\n\trefactoring to match style guidelines", "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": "Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Naushir Patuck <naush@raspberrypi.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Refactor the source files under src/ipa/raspberrypi/controller/rpi/a* to match the\nrecommended formatting guidelines for the libcamera project. The vast majority\nof changes in this commit comprise of switching from snake_case to CamelCase,\nand starting class member functions with a lower case character.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/rpi/agc.cpp | 722 ++++++++++----------\n src/ipa/raspberrypi/controller/rpi/agc.hpp | 130 ++--\n src/ipa/raspberrypi/controller/rpi/alsc.cpp | 639 ++++++++---------\n src/ipa/raspberrypi/controller/rpi/alsc.hpp | 86 +--\n src/ipa/raspberrypi/controller/rpi/awb.cpp | 562 ++++++++-------\n src/ipa/raspberrypi/controller/rpi/awb.hpp | 110 +--\n 6 files changed, 1089 insertions(+), 1160 deletions(-)", "diff": "diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp\nindex f6a9cb0a2cd8..738cf56c6be0 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n@@ -30,7 +30,7 @@ LOG_DEFINE_CATEGORY(RPiAgc)\n \n #define PIPELINE_BITS 13 // seems to be a 13-bit pipeline\n \n-void AgcMeteringMode::Read(boost::property_tree::ptree const ¶ms)\n+void AgcMeteringMode::read(boost::property_tree::ptree const ¶ms)\n {\n \tint num = 0;\n \tfor (auto &p : params.get_child(\"weights\")) {\n@@ -43,265 +43,260 @@ void AgcMeteringMode::Read(boost::property_tree::ptree const ¶ms)\n }\n \n static std::string\n-read_metering_modes(std::map<std::string, AgcMeteringMode> &metering_modes,\n-\t\t boost::property_tree::ptree const ¶ms)\n+readMeteringModes(std::map<std::string, AgcMeteringMode> &meteringModes,\n+\t\t boost::property_tree::ptree const ¶ms)\n {\n \tstd::string first;\n \tfor (auto &p : params) {\n-\t\tAgcMeteringMode metering_mode;\n-\t\tmetering_mode.Read(p.second);\n-\t\tmetering_modes[p.first] = std::move(metering_mode);\n+\t\tAgcMeteringMode meteringMode;\n+\t\tmeteringMode.read(p.second);\n+\t\tmeteringModes[p.first] = std::move(meteringMode);\n \t\tif (first.empty())\n \t\t\tfirst = p.first;\n \t}\n \treturn first;\n }\n \n-static int read_list(std::vector<double> &list,\n-\t\t boost::property_tree::ptree const ¶ms)\n+static int readList(std::vector<double> &list,\n+\t\t boost::property_tree::ptree const ¶ms)\n {\n \tfor (auto &p : params)\n \t\tlist.push_back(p.second.get_value<double>());\n \treturn list.size();\n }\n \n-static int read_list(std::vector<Duration> &list,\n-\t\t boost::property_tree::ptree const ¶ms)\n+static int readList(std::vector<Duration> &list,\n+\t\t boost::property_tree::ptree const ¶ms)\n {\n \tfor (auto &p : params)\n \t\tlist.push_back(p.second.get_value<double>() * 1us);\n \treturn list.size();\n }\n \n-void AgcExposureMode::Read(boost::property_tree::ptree const ¶ms)\n+void AgcExposureMode::read(boost::property_tree::ptree const ¶ms)\n {\n-\tint num_shutters = read_list(shutter, params.get_child(\"shutter\"));\n-\tint num_ags = read_list(gain, params.get_child(\"gain\"));\n-\tif (num_shutters < 2 || num_ags < 2)\n+\tint numShutters = readList(shutter, params.get_child(\"shutter\"));\n+\tint numAgs = readList(gain, params.get_child(\"gain\"));\n+\tif (numShutters < 2 || numAgs < 2)\n \t\tthrow std::runtime_error(\n \t\t\t\"AgcConfig: must have at least two entries in exposure profile\");\n-\tif (num_shutters != num_ags)\n+\tif (numShutters != numAgs)\n \t\tthrow std::runtime_error(\n \t\t\t\"AgcConfig: expect same number of exposure and gain entries in exposure profile\");\n }\n \n static std::string\n-read_exposure_modes(std::map<std::string, AgcExposureMode> &exposure_modes,\n-\t\t boost::property_tree::ptree const ¶ms)\n+readExposureModes(std::map<std::string, AgcExposureMode> &exposureModes,\n+\t\t boost::property_tree::ptree const ¶ms)\n {\n \tstd::string first;\n \tfor (auto &p : params) {\n-\t\tAgcExposureMode exposure_mode;\n-\t\texposure_mode.Read(p.second);\n-\t\texposure_modes[p.first] = std::move(exposure_mode);\n+\t\tAgcExposureMode exposureMode;\n+\t\texposureMode.read(p.second);\n+\t\texposureModes[p.first] = std::move(exposureMode);\n \t\tif (first.empty())\n \t\t\tfirst = p.first;\n \t}\n \treturn first;\n }\n \n-void AgcConstraint::Read(boost::property_tree::ptree const ¶ms)\n+void AgcConstraint::read(boost::property_tree::ptree const ¶ms)\n {\n-\tstd::string bound_string = params.get<std::string>(\"bound\", \"\");\n-\ttransform(bound_string.begin(), bound_string.end(),\n-\t\t bound_string.begin(), ::toupper);\n-\tif (bound_string != \"UPPER\" && bound_string != \"LOWER\")\n+\tstd::string boundString = params.get<std::string>(\"bound\", \"\");\n+\ttransform(boundString.begin(), boundString.end(),\n+\t\t boundString.begin(), ::toupper);\n+\tif (boundString != \"UPPER\" && boundString != \"LOWER\")\n \t\tthrow std::runtime_error(\n \t\t\t\"AGC constraint type should be UPPER or LOWER\");\n-\tbound = bound_string == \"UPPER\" ? Bound::UPPER : Bound::LOWER;\n-\tq_lo = params.get<double>(\"q_lo\");\n-\tq_hi = params.get<double>(\"q_hi\");\n-\tY_target.Read(params.get_child(\"y_target\"));\n+\tbound = boundString == \"UPPER\" ? Bound::UPPER : Bound::LOWER;\n+\tqLo = params.get<double>(\"q_lo\");\n+\tqHi = params.get<double>(\"q_hi\");\n+\tyTarget.read(params.get_child(\"y_target\"));\n }\n \n static AgcConstraintMode\n-read_constraint_mode(boost::property_tree::ptree const ¶ms)\n+readConstraintMode(boost::property_tree::ptree const ¶ms)\n {\n \tAgcConstraintMode mode;\n \tfor (auto &p : params) {\n \t\tAgcConstraint constraint;\n-\t\tconstraint.Read(p.second);\n+\t\tconstraint.read(p.second);\n \t\tmode.push_back(std::move(constraint));\n \t}\n \treturn mode;\n }\n \n-static std::string read_constraint_modes(\n-\tstd::map<std::string, AgcConstraintMode> &constraint_modes,\n-\tboost::property_tree::ptree const ¶ms)\n+static std::string readConstraintModes(std::map<std::string, AgcConstraintMode> &constraintModes,\n+\t\t\t\t boost::property_tree::ptree const ¶ms)\n {\n \tstd::string first;\n \tfor (auto &p : params) {\n-\t\tconstraint_modes[p.first] = read_constraint_mode(p.second);\n+\t\tconstraintModes[p.first] = readConstraintMode(p.second);\n \t\tif (first.empty())\n \t\t\tfirst = p.first;\n \t}\n \treturn first;\n }\n \n-void AgcConfig::Read(boost::property_tree::ptree const ¶ms)\n+void AgcConfig::read(boost::property_tree::ptree const ¶ms)\n {\n \tLOG(RPiAgc, Debug) << \"AgcConfig\";\n-\tdefault_metering_mode = read_metering_modes(\n-\t\tmetering_modes, params.get_child(\"metering_modes\"));\n-\tdefault_exposure_mode = read_exposure_modes(\n-\t\texposure_modes, params.get_child(\"exposure_modes\"));\n-\tdefault_constraint_mode = read_constraint_modes(\n-\t\tconstraint_modes, params.get_child(\"constraint_modes\"));\n-\tY_target.Read(params.get_child(\"y_target\"));\n+\tdefaultMeteringMode = readMeteringModes(meteringModes, params.get_child(\"metering_modes\"));\n+\tdefaultExposureMode = readExposureModes(exposureModes, params.get_child(\"exposure_modes\"));\n+\tdefaultConstraintMode = readConstraintModes(constraintModes, params.get_child(\"constraint_modes\"));\n+\tyTarget.read(params.get_child(\"y_target\"));\n \tspeed = params.get<double>(\"speed\", 0.2);\n-\tstartup_frames = params.get<uint16_t>(\"startup_frames\", 10);\n-\tconvergence_frames = params.get<unsigned int>(\"convergence_frames\", 6);\n-\tfast_reduce_threshold =\n-\t\tparams.get<double>(\"fast_reduce_threshold\", 0.4);\n-\tbase_ev = params.get<double>(\"base_ev\", 1.0);\n+\tstartupFrames = params.get<uint16_t>(\"startup_frames\", 10);\n+\tconvergenceFrames = params.get<unsigned int>(\"convergence_frames\", 6);\n+\tfastReduceThreshold = params.get<double>(\"fast_reduce_threshold\", 0.4);\n+\tbaseEv = params.get<double>(\"base_ev\", 1.0);\n \t// Start with quite a low value as ramping up is easier than ramping down.\n-\tdefault_exposure_time = params.get<double>(\"default_exposure_time\", 1000) * 1us;\n-\tdefault_analogue_gain = params.get<double>(\"default_analogue_gain\", 1.0);\n+\tdefaultExposureTime = params.get<double>(\"default_exposure_time\", 1000) * 1us;\n+\tdefaultAnalogueGain = params.get<double>(\"default_analogueGain\", 1.0);\n }\n \n Agc::ExposureValues::ExposureValues()\n-\t: shutter(0s), analogue_gain(0),\n-\t total_exposure(0s), total_exposure_no_dg(0s)\n+\t: shutter(0s), analogueGain(0),\n+\t totalExposure(0s), totalExposureNoDG(0s)\n {\n }\n \n Agc::Agc(Controller *controller)\n-\t: AgcAlgorithm(controller), metering_mode_(nullptr),\n-\t exposure_mode_(nullptr), constraint_mode_(nullptr),\n-\t frame_count_(0), lock_count_(0),\n-\t last_target_exposure_(0s), last_sensitivity_(0.0),\n-\t ev_(1.0), flicker_period_(0s),\n-\t max_shutter_(0s), fixed_shutter_(0s), fixed_analogue_gain_(0.0)\n+\t: AgcAlgorithm(controller), meteringMode_(nullptr),\n+\t exposureMode_(nullptr), constraintMode_(nullptr),\n+\t frameCount_(0), lockCount_(0),\n+\t lastTargetExposure_(0s), lastSensitivity_(0.0),\n+\t ev_(1.0), flickerPeriod_(0s),\n+\t maxShutter_(0s), fixedShutter_(0s), fixedAnalogueGain_(0.0)\n {\n \tmemset(&awb_, 0, sizeof(awb_));\n-\t// Setting status_.total_exposure_value_ to zero initially tells us\n+\t// Setting status_.totalExposureValue_ to zero initially tells us\n \t// it's not been calculated yet (i.e. Process hasn't yet run).\n \tmemset(&status_, 0, sizeof(status_));\n \tstatus_.ev = ev_;\n }\n \n-char const *Agc::Name() const\n+char const *Agc::name() const\n {\n \treturn NAME;\n }\n \n-void Agc::Read(boost::property_tree::ptree const ¶ms)\n+void Agc::read(boost::property_tree::ptree const ¶ms)\n {\n \tLOG(RPiAgc, Debug) << \"Agc\";\n-\tconfig_.Read(params);\n+\tconfig_.read(params);\n \t// Set the config's defaults (which are the first ones it read) as our\n \t// current modes, until someone changes them. (they're all known to\n \t// exist at this point)\n-\tmetering_mode_name_ = config_.default_metering_mode;\n-\tmetering_mode_ = &config_.metering_modes[metering_mode_name_];\n-\texposure_mode_name_ = config_.default_exposure_mode;\n-\texposure_mode_ = &config_.exposure_modes[exposure_mode_name_];\n-\tconstraint_mode_name_ = config_.default_constraint_mode;\n-\tconstraint_mode_ = &config_.constraint_modes[constraint_mode_name_];\n+\tmeteringModeName_ = config_.defaultMeteringMode;\n+\tmeteringMode_ = &config_.meteringModes[meteringModeName_];\n+\texposureModeName_ = config_.defaultExposureMode;\n+\texposureMode_ = &config_.exposureModes[exposureModeName_];\n+\tconstraintModeName_ = config_.defaultConstraintMode;\n+\tconstraintMode_ = &config_.constraintModes[constraintModeName_];\n \t// Set up the \"last shutter/gain\" values, in case AGC starts \"disabled\".\n-\tstatus_.shutter_time = config_.default_exposure_time;\n-\tstatus_.analogue_gain = config_.default_analogue_gain;\n+\tstatus_.shutterTime = config_.defaultExposureTime;\n+\tstatus_.analogueGain = config_.defaultAnalogueGain;\n }\n \n-bool Agc::IsPaused() const\n+bool Agc::isPaused() const\n {\n \treturn false;\n }\n \n-void Agc::Pause()\n+void Agc::pause()\n {\n-\tfixed_shutter_ = status_.shutter_time;\n-\tfixed_analogue_gain_ = status_.analogue_gain;\n+\tfixedShutter_ = status_.shutterTime;\n+\tfixedAnalogueGain_ = status_.analogueGain;\n }\n \n-void Agc::Resume()\n+void Agc::resume()\n {\n-\tfixed_shutter_ = 0s;\n-\tfixed_analogue_gain_ = 0;\n+\tfixedShutter_ = 0s;\n+\tfixedAnalogueGain_ = 0;\n }\n \n-unsigned int Agc::GetConvergenceFrames() const\n+unsigned int Agc::getConvergenceFrames() const\n {\n \t// If shutter and gain have been explicitly set, there is no\n \t// convergence to happen, so no need to drop any frames - return zero.\n-\tif (fixed_shutter_ && fixed_analogue_gain_)\n+\tif (fixedShutter_ && fixedAnalogueGain_)\n \t\treturn 0;\n \telse\n-\t\treturn config_.convergence_frames;\n+\t\treturn config_.convergenceFrames;\n }\n \n-void Agc::SetEv(double ev)\n+void Agc::setEv(double ev)\n {\n \tev_ = ev;\n }\n \n-void Agc::SetFlickerPeriod(Duration flicker_period)\n+void Agc::setFlickerPeriod(Duration flickerPeriod)\n {\n-\tflicker_period_ = flicker_period;\n+\tflickerPeriod_ = flickerPeriod;\n }\n \n-void Agc::SetMaxShutter(Duration max_shutter)\n+void Agc::setMaxShutter(Duration maxShutter)\n {\n-\tmax_shutter_ = max_shutter;\n+\tmaxShutter_ = maxShutter;\n }\n \n-void Agc::SetFixedShutter(Duration fixed_shutter)\n+void Agc::setFixedShutter(Duration fixedShutter)\n {\n-\tfixed_shutter_ = fixed_shutter;\n+\tfixedShutter_ = fixedShutter;\n \t// Set this in case someone calls Pause() straight after.\n-\tstatus_.shutter_time = clipShutter(fixed_shutter_);\n+\tstatus_.shutterTime = clipShutter(fixedShutter_);\n }\n \n-void Agc::SetFixedAnalogueGain(double fixed_analogue_gain)\n+void Agc::setFixedAnalogueGain(double fixedAnalogueGain)\n {\n-\tfixed_analogue_gain_ = fixed_analogue_gain;\n+\tfixedAnalogueGain_ = fixedAnalogueGain_;\n \t// Set this in case someone calls Pause() straight after.\n-\tstatus_.analogue_gain = fixed_analogue_gain;\n+\tstatus_.analogueGain = fixedAnalogueGain;\n }\n \n-void Agc::SetMeteringMode(std::string const &metering_mode_name)\n+void Agc::setMeteringMode(std::string const &meteringModeName)\n {\n-\tmetering_mode_name_ = metering_mode_name;\n+\tmeteringModeName_ = meteringModeName;\n }\n \n-void Agc::SetExposureMode(std::string const &exposure_mode_name)\n+void Agc::setExposureMode(std::string const &exposureModeName)\n {\n-\texposure_mode_name_ = exposure_mode_name;\n+\texposureModeName_ = exposureModeName;\n }\n \n-void Agc::SetConstraintMode(std::string const &constraint_mode_name)\n+void Agc::setConstraintMode(std::string const &constraintModeName)\n {\n-\tconstraint_mode_name_ = constraint_mode_name;\n+\tconstraintModeName_ = constraintModeName;\n }\n \n-void Agc::SwitchMode(CameraMode const &camera_mode,\n+void Agc::switchMode(CameraMode const &cameraMode,\n \t\t Metadata *metadata)\n {\n \t/* AGC expects the mode sensitivity always to be non-zero. */\n-\tASSERT(camera_mode.sensitivity);\n+\tASSERT(cameraMode.sensitivity);\n \n \thousekeepConfig();\n \n-\tDuration fixed_shutter = clipShutter(fixed_shutter_);\n-\tif (fixed_shutter && fixed_analogue_gain_) {\n+\tDuration fixedShutter = clipShutter(fixedShutter_);\n+\tif (fixedShutter && fixedAnalogueGain_) {\n \t\t// We're going to reset the algorithm here with these fixed values.\n \n \t\tfetchAwbStatus(metadata);\n-\t\tdouble min_colour_gain = std::min({ awb_.gain_r, awb_.gain_g, awb_.gain_b, 1.0 });\n-\t\tASSERT(min_colour_gain != 0.0);\n+\t\tdouble minColourGain = std::min({ awb_.gainR, awb_.gainG, awb_.gainB, 1.0 });\n+\t\tASSERT(minColourGain != 0.0);\n \n \t\t// This is the equivalent of computeTargetExposure and applyDigitalGain.\n-\t\ttarget_.total_exposure_no_dg = fixed_shutter * fixed_analogue_gain_;\n-\t\ttarget_.total_exposure = target_.total_exposure_no_dg / min_colour_gain;\n+\t\ttarget_.totalExposureNoDG = fixedShutter_ * fixedAnalogueGain_;\n+\t\ttarget_.totalExposure = target_.totalExposureNoDG / minColourGain;\n \n \t\t// Equivalent of filterExposure. This resets any \"history\".\n \t\tfiltered_ = target_;\n \n \t\t// Equivalent of divideUpExposure.\n-\t\tfiltered_.shutter = fixed_shutter;\n-\t\tfiltered_.analogue_gain = fixed_analogue_gain_;\n-\t} else if (status_.total_exposure_value) {\n+\t\tfiltered_.shutter = fixedShutter;\n+\t\tfiltered_.analogueGain = fixedAnalogueGain_;\n+\t} else if (status_.totalExposureValue) {\n \t\t// On a mode switch, various things could happen:\n \t\t// - the exposure profile might change\n \t\t// - a fixed exposure or gain might be set\n@@ -310,11 +305,11 @@ void Agc::SwitchMode(CameraMode const &camera_mode,\n \t\t// that we just need to re-divide the exposure/gain according to the\n \t\t// current exposure profile, which takes care of everything else.\n \n-\t\tdouble ratio = last_sensitivity_ / camera_mode.sensitivity;\n-\t\ttarget_.total_exposure_no_dg *= ratio;\n-\t\ttarget_.total_exposure *= ratio;\n-\t\tfiltered_.total_exposure_no_dg *= ratio;\n-\t\tfiltered_.total_exposure *= ratio;\n+\t\tdouble ratio = lastSensitivity_ / cameraMode.sensitivity;\n+\t\ttarget_.totalExposureNoDG *= ratio;\n+\t\ttarget_.totalExposure *= ratio;\n+\t\tfiltered_.totalExposureNoDG *= ratio;\n+\t\tfiltered_.totalExposure *= ratio;\n \n \t\tdivideUpExposure();\n \t} else {\n@@ -324,114 +319,110 @@ void Agc::SwitchMode(CameraMode const &camera_mode,\n \t\t// for any that weren't set.\n \n \t\t// Equivalent of divideUpExposure.\n-\t\tfiltered_.shutter = fixed_shutter ? fixed_shutter : config_.default_exposure_time;\n-\t\tfiltered_.analogue_gain = fixed_analogue_gain_ ? fixed_analogue_gain_ : config_.default_analogue_gain;\n+\t\tfiltered_.shutter = fixedShutter ? fixedShutter : config_.defaultExposureTime;\n+\t\tfiltered_.analogueGain = fixedAnalogueGain_ ? fixedAnalogueGain_ : config_.defaultAnalogueGain;\n \t}\n \n \twriteAndFinish(metadata, false);\n \n \t// We must remember the sensitivity of this mode for the next SwitchMode.\n-\tlast_sensitivity_ = camera_mode.sensitivity;\n+\tlastSensitivity_ = cameraMode.sensitivity;\n }\n \n-void Agc::Prepare(Metadata *image_metadata)\n+void Agc::prepare(Metadata *imageMetadata)\n {\n-\tstatus_.digital_gain = 1.0;\n-\tfetchAwbStatus(image_metadata); // always fetch it so that Process knows it's been done\n+\tstatus_.digitalGain = 1.0;\n+\tfetchAwbStatus(imageMetadata); // always fetch it so that Process knows it's been done\n \n-\tif (status_.total_exposure_value) {\n+\tif (status_.totalExposureValue) {\n \t\t// Process has run, so we have meaningful values.\n-\t\tDeviceStatus device_status;\n-\t\tif (image_metadata->Get(\"device.status\", device_status) == 0) {\n-\t\t\tDuration actual_exposure = device_status.shutter_speed *\n-\t\t\t\t\t\t device_status.analogue_gain;\n-\t\t\tif (actual_exposure) {\n-\t\t\t\tstatus_.digital_gain =\n-\t\t\t\t\tstatus_.total_exposure_value /\n-\t\t\t\t\tactual_exposure;\n-\t\t\t\tLOG(RPiAgc, Debug) << \"Want total exposure \" << status_.total_exposure_value;\n+\t\tDeviceStatus deviceStatus;\n+\t\tif (imageMetadata->get(\"device.status\", deviceStatus) == 0) {\n+\t\t\tDuration actualExposure = deviceStatus.shutterSpeed *\n+\t\t\t\t\t\t deviceStatus.analogueGain;\n+\t\t\tif (actualExposure) {\n+\t\t\t\tstatus_.digitalGain = status_.totalExposureValue / actualExposure;\n+\t\t\t\tLOG(RPiAgc, Debug) << \"Want total exposure \" << status_.totalExposureValue;\n \t\t\t\t// Never ask for a gain < 1.0, and also impose\n \t\t\t\t// some upper limit. Make it customisable?\n-\t\t\t\tstatus_.digital_gain = std::max(\n-\t\t\t\t\t1.0,\n-\t\t\t\t\tstd::min(status_.digital_gain, 4.0));\n-\t\t\t\tLOG(RPiAgc, Debug) << \"Actual exposure \" << actual_exposure;\n-\t\t\t\tLOG(RPiAgc, Debug) << \"Use digital_gain \" << status_.digital_gain;\n+\t\t\t\tstatus_.digitalGain = std::max(1.0, std::min(status_.digitalGain, 4.0));\n+\t\t\t\tLOG(RPiAgc, Debug) << \"Actual exposure \" << actualExposure;\n+\t\t\t\tLOG(RPiAgc, Debug) << \"Use digital_gain \" << status_.digitalGain;\n \t\t\t\tLOG(RPiAgc, Debug) << \"Effective exposure \"\n-\t\t\t\t\t\t << actual_exposure * status_.digital_gain;\n+\t\t\t\t\t\t << actualExposure * status_.digitalGain;\n \t\t\t\t// Decide whether AEC/AGC has converged.\n-\t\t\t\tupdateLockStatus(device_status);\n+\t\t\t\tupdateLockStatus(deviceStatus);\n \t\t\t}\n \t\t} else\n-\t\t\tLOG(RPiAgc, Warning) << Name() << \": no device metadata\";\n-\t\timage_metadata->Set(\"agc.status\", status_);\n+\t\t\tLOG(RPiAgc, Warning) << name() << \": no device metadata\";\n+\t\timageMetadata->set(\"agc.status\", status_);\n \t}\n }\n \n-void Agc::Process(StatisticsPtr &stats, Metadata *image_metadata)\n+void Agc::process(StatisticsPtr &stats, Metadata *imageMetadata)\n {\n-\tframe_count_++;\n+\tframeCount_++;\n \t// First a little bit of housekeeping, fetching up-to-date settings and\n \t// configuration, that kind of thing.\n \thousekeepConfig();\n \t// Get the current exposure values for the frame that's just arrived.\n-\tfetchCurrentExposure(image_metadata);\n+\tfetchCurrentExposure(imageMetadata);\n \t// Compute the total gain we require relative to the current exposure.\n-\tdouble gain, target_Y;\n-\tcomputeGain(stats.get(), image_metadata, gain, target_Y);\n+\tdouble gain, targetY;\n+\tcomputeGain(stats.get(), imageMetadata, gain, targetY);\n \t// Now compute the target (final) exposure which we think we want.\n \tcomputeTargetExposure(gain);\n \t// Some of the exposure has to be applied as digital gain, so work out\n \t// what that is. This function also tells us whether it's decided to\n \t// \"desaturate\" the image more quickly.\n-\tbool desaturate = applyDigitalGain(gain, target_Y);\n+\tbool desaturate = applyDigitalGain(gain, targetY);\n \t// The results have to be filtered so as not to change too rapidly.\n \tfilterExposure(desaturate);\n \t// The last thing is to divide up the exposure value into a shutter time\n-\t// and analogue_gain, according to the current exposure mode.\n+\t// and analogue gain, according to the current exposure mode.\n \tdivideUpExposure();\n \t// Finally advertise what we've done.\n-\twriteAndFinish(image_metadata, desaturate);\n+\twriteAndFinish(imageMetadata, desaturate);\n }\n \n-void Agc::updateLockStatus(DeviceStatus const &device_status)\n+void Agc::updateLockStatus(DeviceStatus const &deviceStatus)\n {\n-\tconst double ERROR_FACTOR = 0.10; // make these customisable?\n-\tconst int MAX_LOCK_COUNT = 5;\n-\t// Reset \"lock count\" when we exceed this multiple of ERROR_FACTOR\n-\tconst double RESET_MARGIN = 1.5;\n+\tconst double errorFactor = 0.10; // make these customisable?\n+\tconst int maxLockCount = 5;\n+\t// Reset \"lock count\" when we exceed this multiple of errorFactor\n+\tconst double resetMargin = 1.5;\n \n \t// Add 200us to the exposure time error to allow for line quantisation.\n-\tDuration exposure_error = last_device_status_.shutter_speed * ERROR_FACTOR + 200us;\n-\tdouble gain_error = last_device_status_.analogue_gain * ERROR_FACTOR;\n-\tDuration target_error = last_target_exposure_ * ERROR_FACTOR;\n+\tDuration exposureError = lastDeviceStatus_.shutterSpeed * errorFactor + 200us;\n+\tdouble gainError = lastDeviceStatus_.analogueGain * errorFactor;\n+\tDuration targetError = lastTargetExposure_ * errorFactor;\n \n \t// Note that we don't know the exposure/gain limits of the sensor, so\n \t// the values we keep requesting may be unachievable. For this reason\n \t// we only insist that we're close to values in the past few frames.\n-\tif (device_status.shutter_speed > last_device_status_.shutter_speed - exposure_error &&\n-\t device_status.shutter_speed < last_device_status_.shutter_speed + exposure_error &&\n-\t device_status.analogue_gain > last_device_status_.analogue_gain - gain_error &&\n-\t device_status.analogue_gain < last_device_status_.analogue_gain + gain_error &&\n-\t status_.target_exposure_value > last_target_exposure_ - target_error &&\n-\t status_.target_exposure_value < last_target_exposure_ + target_error)\n-\t\tlock_count_ = std::min(lock_count_ + 1, MAX_LOCK_COUNT);\n-\telse if (device_status.shutter_speed < last_device_status_.shutter_speed - RESET_MARGIN * exposure_error ||\n-\t\t device_status.shutter_speed > last_device_status_.shutter_speed + RESET_MARGIN * exposure_error ||\n-\t\t device_status.analogue_gain < last_device_status_.analogue_gain - RESET_MARGIN * gain_error ||\n-\t\t device_status.analogue_gain > last_device_status_.analogue_gain + RESET_MARGIN * gain_error ||\n-\t\t status_.target_exposure_value < last_target_exposure_ - RESET_MARGIN * target_error ||\n-\t\t status_.target_exposure_value > last_target_exposure_ + RESET_MARGIN * target_error)\n-\t\tlock_count_ = 0;\n-\n-\tlast_device_status_ = device_status;\n-\tlast_target_exposure_ = status_.target_exposure_value;\n-\n-\tLOG(RPiAgc, Debug) << \"Lock count updated to \" << lock_count_;\n-\tstatus_.locked = lock_count_ == MAX_LOCK_COUNT;\n-}\n-\n-static void copy_string(std::string const &s, char *d, size_t size)\n+\tif (deviceStatus.shutterSpeed > lastDeviceStatus_.shutterSpeed - exposureError &&\n+\t deviceStatus.shutterSpeed < lastDeviceStatus_.shutterSpeed + exposureError &&\n+\t deviceStatus.analogueGain > lastDeviceStatus_.analogueGain - gainError &&\n+\t deviceStatus.analogueGain < lastDeviceStatus_.analogueGain + gainError &&\n+\t status_.targetExposureValue > lastTargetExposure_ - targetError &&\n+\t status_.targetExposureValue < lastTargetExposure_ + targetError)\n+\t\tlockCount_ = std::min(lockCount_ + 1, maxLockCount);\n+\telse if (deviceStatus.shutterSpeed < lastDeviceStatus_.shutterSpeed - resetMargin * exposureError ||\n+\t\t deviceStatus.shutterSpeed > lastDeviceStatus_.shutterSpeed + resetMargin * exposureError ||\n+\t\t deviceStatus.analogueGain < lastDeviceStatus_.analogueGain - resetMargin * gainError ||\n+\t\t deviceStatus.analogueGain > lastDeviceStatus_.analogueGain + resetMargin * gainError ||\n+\t\t status_.targetExposureValue < lastTargetExposure_ - resetMargin * targetError ||\n+\t\t status_.targetExposureValue > lastTargetExposure_ + resetMargin * targetError)\n+\t\tlockCount_ = 0;\n+\n+\tlastDeviceStatus_ = deviceStatus;\n+\tlastTargetExposure_ = status_.targetExposureValue;\n+\n+\tLOG(RPiAgc, Debug) << \"Lock count updated to \" << lockCount_;\n+\tstatus_.locked = lockCount_ == maxLockCount;\n+}\n+\n+static void copyString(std::string const &s, char *d, size_t size)\n {\n \tsize_t length = s.copy(d, size - 1);\n \td[length] = '\\0';\n@@ -441,97 +432,97 @@ void Agc::housekeepConfig()\n {\n \t// First fetch all the up-to-date settings, so no one else has to do it.\n \tstatus_.ev = ev_;\n-\tstatus_.fixed_shutter = clipShutter(fixed_shutter_);\n-\tstatus_.fixed_analogue_gain = fixed_analogue_gain_;\n-\tstatus_.flicker_period = flicker_period_;\n-\tLOG(RPiAgc, Debug) << \"ev \" << status_.ev << \" fixed_shutter \"\n-\t\t\t << status_.fixed_shutter << \" fixed_analogue_gain \"\n-\t\t\t << status_.fixed_analogue_gain;\n+\tstatus_.fixedShutter = clipShutter(fixedShutter_);\n+\tstatus_.fixedAnalogueGain = fixedAnalogueGain_;\n+\tstatus_.flickerPeriod = flickerPeriod_;\n+\tLOG(RPiAgc, Debug) << \"ev \" << status_.ev << \" fixedShutter \"\n+\t\t\t << status_.fixedShutter << \" fixedAnalogueGain \"\n+\t\t\t << status_.fixedAnalogueGain;\n \t// Make sure the \"mode\" pointers point to the up-to-date things, if\n \t// they've changed.\n-\tif (strcmp(metering_mode_name_.c_str(), status_.metering_mode)) {\n-\t\tauto it = config_.metering_modes.find(metering_mode_name_);\n-\t\tif (it == config_.metering_modes.end())\n+\tif (strcmp(meteringModeName_.c_str(), status_.meteringMode)) {\n+\t\tauto it = config_.meteringModes.find(meteringModeName_);\n+\t\tif (it == config_.meteringModes.end())\n \t\t\tthrow std::runtime_error(\"Agc: no metering mode \" +\n-\t\t\t\t\t\t metering_mode_name_);\n-\t\tmetering_mode_ = &it->second;\n-\t\tcopy_string(metering_mode_name_, status_.metering_mode,\n-\t\t\t sizeof(status_.metering_mode));\n+\t\t\t\t\t\t meteringModeName_);\n+\t\tmeteringMode_ = &it->second;\n+\t\tcopyString(meteringModeName_, status_.meteringMode,\n+\t\t\t sizeof(status_.meteringMode));\n \t}\n-\tif (strcmp(exposure_mode_name_.c_str(), status_.exposure_mode)) {\n-\t\tauto it = config_.exposure_modes.find(exposure_mode_name_);\n-\t\tif (it == config_.exposure_modes.end())\n+\tif (strcmp(exposureModeName_.c_str(), status_.exposureMode)) {\n+\t\tauto it = config_.exposureModes.find(exposureModeName_);\n+\t\tif (it == config_.exposureModes.end())\n \t\t\tthrow std::runtime_error(\"Agc: no exposure profile \" +\n-\t\t\t\t\t\t exposure_mode_name_);\n-\t\texposure_mode_ = &it->second;\n-\t\tcopy_string(exposure_mode_name_, status_.exposure_mode,\n-\t\t\t sizeof(status_.exposure_mode));\n+\t\t\t\t\t\t exposureModeName_);\n+\t\texposureMode_ = &it->second;\n+\t\tcopyString(exposureModeName_, status_.exposureMode,\n+\t\t\t sizeof(status_.exposureMode));\n \t}\n-\tif (strcmp(constraint_mode_name_.c_str(), status_.constraint_mode)) {\n+\tif (strcmp(constraintModeName_.c_str(), status_.constraint_mode)) {\n \t\tauto it =\n-\t\t\tconfig_.constraint_modes.find(constraint_mode_name_);\n-\t\tif (it == config_.constraint_modes.end())\n+\t\t\tconfig_.constraintModes.find(constraintModeName_);\n+\t\tif (it == config_.constraintModes.end())\n \t\t\tthrow std::runtime_error(\"Agc: no constraint list \" +\n-\t\t\t\t\t\t constraint_mode_name_);\n-\t\tconstraint_mode_ = &it->second;\n-\t\tcopy_string(constraint_mode_name_, status_.constraint_mode,\n-\t\t\t sizeof(status_.constraint_mode));\n+\t\t\t\t\t\t constraintModeName_);\n+\t\tconstraintMode_ = &it->second;\n+\t\tcopyString(constraintModeName_, status_.constraint_mode,\n+\t\t\t sizeof(status_.constraint_mode));\n \t}\n-\tLOG(RPiAgc, Debug) << \"exposure_mode \"\n-\t\t\t << exposure_mode_name_ << \" constraint_mode \"\n-\t\t\t << constraint_mode_name_ << \" metering_mode \"\n-\t\t\t << metering_mode_name_;\n+\tLOG(RPiAgc, Debug) << \"exposureMode \"\n+\t\t\t << exposureModeName_ << \" constraint_mode \"\n+\t\t\t << constraintModeName_ << \" meteringMode \"\n+\t\t\t << meteringModeName_;\n }\n \n-void Agc::fetchCurrentExposure(Metadata *image_metadata)\n+void Agc::fetchCurrentExposure(Metadata *imageMetadata)\n {\n-\tstd::unique_lock<Metadata> lock(*image_metadata);\n-\tDeviceStatus *device_status =\n-\t\timage_metadata->GetLocked<DeviceStatus>(\"device.status\");\n-\tif (!device_status)\n+\tstd::unique_lock<Metadata> lock(*imageMetadata);\n+\tDeviceStatus *deviceStatus =\n+\t\timageMetadata->getLocked<DeviceStatus>(\"device.status\");\n+\tif (!deviceStatus)\n \t\tthrow std::runtime_error(\"Agc: no device metadata\");\n-\tcurrent_.shutter = device_status->shutter_speed;\n-\tcurrent_.analogue_gain = device_status->analogue_gain;\n-\tAgcStatus *agc_status =\n-\t\timage_metadata->GetLocked<AgcStatus>(\"agc.status\");\n-\tcurrent_.total_exposure = agc_status ? agc_status->total_exposure_value : 0s;\n-\tcurrent_.total_exposure_no_dg = current_.shutter * current_.analogue_gain;\n+\tcurrent_.shutter = deviceStatus->shutterSpeed;\n+\tcurrent_.analogueGain = deviceStatus->analogueGain;\n+\tAgcStatus *agcStatus =\n+\t\timageMetadata->getLocked<AgcStatus>(\"agc.status\");\n+\tcurrent_.totalExposure = agcStatus ? agcStatus->totalExposureValue : 0s;\n+\tcurrent_.totalExposureNoDG = current_.shutter * current_.analogueGain;\n }\n \n-void Agc::fetchAwbStatus(Metadata *image_metadata)\n+void Agc::fetchAwbStatus(Metadata *imageMetadata)\n {\n-\tawb_.gain_r = 1.0; // in case not found in metadata\n-\tawb_.gain_g = 1.0;\n-\tawb_.gain_b = 1.0;\n-\tif (image_metadata->Get(\"awb.status\", awb_) != 0)\n+\tawb_.gainR = 1.0; // in case not found in metadata\n+\tawb_.gainG = 1.0;\n+\tawb_.gainB = 1.0;\n+\tif (imageMetadata->get(\"awb.status\", awb_) != 0)\n \t\tLOG(RPiAgc, Debug) << \"Agc: no AWB status found\";\n }\n \n-static double compute_initial_Y(bcm2835_isp_stats *stats, AwbStatus const &awb,\n-\t\t\t\tdouble weights[], double gain)\n+static double computeInitialY(bcm2835_isp_stats *stats, AwbStatus const &awb,\n+\t\t\t double 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+\tdouble rSum = 0, gSum = 0, bSum = 0, pixelSum = 0;\n \tfor (int i = 0; i < AGC_STATS_SIZE; 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\tdouble rAcc = std::min(regions[i].r_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted);\n+\t\tdouble gAcc = std::min(regions[i].g_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted);\n+\t\tdouble bAcc = std::min(regions[i].b_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted);\n+\t\trSum += rAcc * weights[i];\n+\t\tgSum += gAcc * weights[i];\n+\t\tbSum += bAcc * weights[i];\n+\t\tpixelSum += counted * weights[i];\n \t}\n-\tif (pixel_sum == 0.0) {\n+\tif (pixelSum == 0.0) {\n \t\tLOG(RPiAgc, Warning) << \"compute_initial_Y: pixel_sum is zero\";\n \t\treturn 0;\n \t}\n-\tdouble Y_sum = R_sum * awb.gain_r * .299 +\n-\t\t G_sum * awb.gain_g * .587 +\n-\t\t B_sum * awb.gain_b * .114;\n-\treturn Y_sum / pixel_sum / (1 << PIPELINE_BITS);\n+\tdouble ySum = rSum * awb.gainR * .299 +\n+\t\t gSum * awb.gainG * .587 +\n+\t\t bSum * awb.gainB * .114;\n+\treturn ySum / pixelSum / (1 << PIPELINE_BITS);\n }\n \n // We handle extra gain through EV by adjusting our Y targets. However, you\n@@ -542,108 +533,102 @@ static double compute_initial_Y(bcm2835_isp_stats *stats, AwbStatus const &awb,\n \n #define EV_GAIN_Y_TARGET_LIMIT 0.9\n \n-static double constraint_compute_gain(AgcConstraint &c, Histogram &h,\n-\t\t\t\t double lux, double ev_gain,\n-\t\t\t\t double &target_Y)\n+static double constraintComputeGain(AgcConstraint &c, Histogram &h, double lux,\n+\t\t\t\t double evGain, double &targetY)\n {\n-\ttarget_Y = c.Y_target.Eval(c.Y_target.Domain().Clip(lux));\n-\ttarget_Y = std::min(EV_GAIN_Y_TARGET_LIMIT, target_Y * ev_gain);\n-\tdouble iqm = h.InterQuantileMean(c.q_lo, c.q_hi);\n-\treturn (target_Y * NUM_HISTOGRAM_BINS) / iqm;\n+\ttargetY = c.yTarget.eval(c.yTarget.domain().clip(lux));\n+\ttargetY = std::min(EV_GAIN_Y_TARGET_LIMIT, targetY * evGain);\n+\tdouble iqm = h.interQuantileMean(c.qLo, c.qHi);\n+\treturn (targetY * NUM_HISTOGRAM_BINS) / iqm;\n }\n \n-void Agc::computeGain(bcm2835_isp_stats *statistics, Metadata *image_metadata,\n-\t\t double &gain, double &target_Y)\n+void Agc::computeGain(bcm2835_isp_stats *statistics, Metadata *imageMetadata,\n+\t\t double &gain, double &targetY)\n {\n \tstruct LuxStatus lux = {};\n \tlux.lux = 400; // default lux level to 400 in case no metadata found\n-\tif (image_metadata->Get(\"lux.status\", lux) != 0)\n+\tif (imageMetadata->get(\"lux.status\", lux) != 0)\n \t\tLOG(RPiAgc, Warning) << \"Agc: no lux level found\";\n \tHistogram h(statistics->hist[0].g_hist, NUM_HISTOGRAM_BINS);\n-\tdouble ev_gain = status_.ev * config_.base_ev;\n+\tdouble evGain = status_.ev * config_.baseEv;\n \t// The initial gain and target_Y come from some of the regions. After\n \t// that we consider the histogram constraints.\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+\ttargetY = config_.yTarget.eval(config_.yTarget.domain().clip(lux.lux));\n+\ttargetY = std::min(EV_GAIN_Y_TARGET_LIMIT, targetY * evGain);\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\tdouble initialY = computeInitialY(statistics, awb_, meteringMode_->weights, gain);\n+\t\tdouble extraGain = std::min(10.0, targetY / (initialY + .001));\n+\t\tgain *= extraGain;\n+\t\tLOG(RPiAgc, Debug) << \"Initial Y \" << initialY << \" target \" << targetY\n \t\t\t\t << \" gives gain \" << gain;\n-\t\tif (extra_gain < 1.01) // close enough\n+\t\tif (extraGain < 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-\t\t\tconstraint_compute_gain(c, h, lux.lux, ev_gain,\n-\t\t\t\t\t\tnew_target_Y);\n+\tfor (auto &c : *constraintMode_) {\n+\t\tdouble newTargetY;\n+\t\tdouble newGain = constraintComputeGain(c, h, lux.lux, evGain, newTargetY);\n \t\tLOG(RPiAgc, Debug) << \"Constraint has target_Y \"\n-\t\t\t\t << new_target_Y << \" giving gain \" << new_gain;\n-\t\tif (c.bound == AgcConstraint::Bound::LOWER &&\n-\t\t new_gain > gain) {\n+\t\t\t\t << newTargetY << \" giving gain \" << newGain;\n+\t\tif (c.bound == AgcConstraint::Bound::LOWER && newGain > gain) {\n \t\t\tLOG(RPiAgc, Debug) << \"Lower bound constraint adopted\";\n-\t\t\tgain = new_gain, target_Y = new_target_Y;\n-\t\t} else if (c.bound == AgcConstraint::Bound::UPPER &&\n-\t\t\t new_gain < gain) {\n+\t\t\tgain = newGain;\n+\t\t\ttargetY = newTargetY;\n+\t\t} else if (c.bound == AgcConstraint::Bound::UPPER && newGain < gain) {\n \t\t\tLOG(RPiAgc, Debug) << \"Upper bound constraint adopted\";\n-\t\t\tgain = new_gain, target_Y = new_target_Y;\n+\t\t\tgain = newGain;\n+\t\t\ttargetY = newTargetY;\n \t\t}\n \t}\n-\tLOG(RPiAgc, Debug) << \"Final gain \" << gain << \" (target_Y \" << target_Y << \" ev \"\n-\t\t\t << status_.ev << \" base_ev \" << config_.base_ev\n+\tLOG(RPiAgc, Debug) << \"Final gain \" << gain << \" (target_Y \" << targetY << \" ev \"\n+\t\t\t << status_.ev << \" base_ev \" << config_.baseEv\n \t\t\t << \")\";\n }\n \n void Agc::computeTargetExposure(double gain)\n {\n-\tif (status_.fixed_shutter && status_.fixed_analogue_gain) {\n+\tif (status_.fixedShutter && status_.fixedAnalogueGain) {\n \t\t// When ag and shutter are both fixed, we need to drive the\n \t\t// total exposure so that we end up with a digital gain of at least\n \t\t// 1/min_colour_gain. Otherwise we'd desaturate channels causing\n \t\t// white to go cyan or magenta.\n-\t\tdouble min_colour_gain = std::min({ awb_.gain_r, awb_.gain_g, awb_.gain_b, 1.0 });\n-\t\tASSERT(min_colour_gain != 0.0);\n-\t\ttarget_.total_exposure =\n-\t\t\tstatus_.fixed_shutter * status_.fixed_analogue_gain / min_colour_gain;\n+\t\tdouble minColourGain = std::min({ awb_.gainR, awb_.gainG, awb_.gainB, 1.0 });\n+\t\tASSERT(minColourGain != 0.0);\n+\t\ttarget_.totalExposure =\n+\t\t\tstatus_.fixedShutter * status_.fixedAnalogueGain / minColourGain;\n \t} else {\n \t\t// The statistics reflect the image without digital gain, so the final\n \t\t// total exposure we're aiming for is:\n-\t\ttarget_.total_exposure = current_.total_exposure_no_dg * gain;\n+\t\ttarget_.totalExposure = current_.totalExposureNoDG * gain;\n \t\t// The final target exposure is also limited to what the exposure\n \t\t// mode allows.\n-\t\tDuration max_shutter = status_.fixed_shutter\n-\t\t\t\t ? status_.fixed_shutter\n-\t\t\t\t : exposure_mode_->shutter.back();\n-\t\tmax_shutter = clipShutter(max_shutter);\n-\t\tDuration max_total_exposure =\n-\t\t\tmax_shutter *\n-\t\t\t(status_.fixed_analogue_gain != 0.0\n-\t\t\t\t ? status_.fixed_analogue_gain\n-\t\t\t\t : exposure_mode_->gain.back());\n-\t\ttarget_.total_exposure = std::min(target_.total_exposure,\n-\t\t\t\t\t\t max_total_exposure);\n+\t\tDuration maxShutter = status_.fixedShutter\n+\t\t\t\t\t ? status_.fixedShutter\n+\t\t\t\t\t : exposureMode_->shutter.back();\n+\t\tmaxShutter = clipShutter(maxShutter);\n+\t\tDuration maxTotalExposure =\n+\t\t\tmaxShutter *\n+\t\t\t(status_.fixedAnalogueGain != 0.0\n+\t\t\t\t ? status_.fixedAnalogueGain\n+\t\t\t\t : exposureMode_->gain.back());\n+\t\ttarget_.totalExposure = std::min(target_.totalExposure, maxTotalExposure);\n \t}\n-\tLOG(RPiAgc, Debug) << \"Target total_exposure \" << target_.total_exposure;\n+\tLOG(RPiAgc, Debug) << \"Target totalExposure \" << target_.totalExposure;\n }\n \n-bool Agc::applyDigitalGain(double gain, double target_Y)\n+bool Agc::applyDigitalGain(double gain, double targetY)\n {\n-\tdouble min_colour_gain = std::min({ awb_.gain_r, awb_.gain_g, awb_.gain_b, 1.0 });\n-\tASSERT(min_colour_gain != 0.0);\n-\tdouble dg = 1.0 / min_colour_gain;\n+\tdouble minColourGain = std::min({ awb_.gainR, awb_.gainG, awb_.gainB, 1.0 });\n+\tASSERT(minColourGain != 0.0);\n+\tdouble dg = 1.0 / minColourGain;\n \t// I think this pipeline subtracts black level and rescales before we\n \t// get the stats, so no need to worry about it.\n \tLOG(RPiAgc, Debug) << \"after AWB, target dg \" << dg << \" gain \" << gain\n-\t\t\t << \" target_Y \" << target_Y;\n+\t\t\t << \" target_Y \" << targetY;\n \t// Finally, if we're trying to reduce exposure but the target_Y is\n \t// \"close\" to 1.0, then the gain computed for that constraint will be\n \t// only slightly less than one, because the measured Y can never be\n@@ -651,13 +636,13 @@ bool Agc::applyDigitalGain(double gain, double target_Y)\n \t// that the exposure can be reduced, de-saturating the image much more\n \t// quickly (and we then approach the correct value more quickly from\n \t// below).\n-\tbool desaturate = target_Y > config_.fast_reduce_threshold &&\n-\t\t\t gain < sqrt(target_Y);\n+\tbool desaturate = targetY > config_.fastReduceThreshold &&\n+\t\t\t gain < sqrt(targetY);\n \tif (desaturate)\n-\t\tdg /= config_.fast_reduce_threshold;\n+\t\tdg /= config_.fastReduceThreshold;\n \tLOG(RPiAgc, Debug) << \"Digital gain \" << dg << \" desaturate? \" << desaturate;\n-\ttarget_.total_exposure_no_dg = target_.total_exposure / dg;\n-\tLOG(RPiAgc, Debug) << \"Target total_exposure_no_dg \" << target_.total_exposure_no_dg;\n+\ttarget_.totalExposureNoDG = target_.totalExposure / dg;\n+\tLOG(RPiAgc, Debug) << \"Target totalExposureNoDG \" << target_.totalExposureNoDG;\n \treturn desaturate;\n }\n \n@@ -666,39 +651,38 @@ void Agc::filterExposure(bool desaturate)\n \tdouble speed = config_.speed;\n \t// AGC adapts instantly if both shutter and gain are directly specified\n \t// or we're in the startup phase.\n-\tif ((status_.fixed_shutter && status_.fixed_analogue_gain) ||\n-\t frame_count_ <= config_.startup_frames)\n+\tif ((status_.fixedShutter && status_.fixedAnalogueGain) ||\n+\t frameCount_ <= config_.startupFrames)\n \t\tspeed = 1.0;\n-\tif (!filtered_.total_exposure) {\n-\t\tfiltered_.total_exposure = target_.total_exposure;\n-\t\tfiltered_.total_exposure_no_dg = target_.total_exposure_no_dg;\n+\tif (!filtered_.totalExposure) {\n+\t\tfiltered_.totalExposure = target_.totalExposure;\n+\t\tfiltered_.totalExposureNoDG = target_.totalExposureNoDG;\n \t} else {\n \t\t// If close to the result go faster, to save making so many\n \t\t// micro-adjustments on the way. (Make this customisable?)\n-\t\tif (filtered_.total_exposure < 1.2 * target_.total_exposure &&\n-\t\t filtered_.total_exposure > 0.8 * target_.total_exposure)\n+\t\tif (filtered_.totalExposure < 1.2 * target_.totalExposure &&\n+\t\t filtered_.totalExposure > 0.8 * target_.totalExposure)\n \t\t\tspeed = sqrt(speed);\n-\t\tfiltered_.total_exposure = speed * target_.total_exposure +\n-\t\t\t\t\t filtered_.total_exposure * (1.0 - speed);\n+\t\tfiltered_.totalExposure = speed * target_.totalExposure +\n+\t\t\t\t\t filtered_.totalExposure * (1.0 - speed);\n \t\t// When desaturing, take a big jump down in exposure_no_dg,\n \t\t// which we'll hide with digital gain.\n \t\tif (desaturate)\n-\t\t\tfiltered_.total_exposure_no_dg =\n-\t\t\t\ttarget_.total_exposure_no_dg;\n+\t\t\tfiltered_.totalExposureNoDG =\n+\t\t\t\ttarget_.totalExposureNoDG;\n \t\telse\n-\t\t\tfiltered_.total_exposure_no_dg =\n-\t\t\t\tspeed * target_.total_exposure_no_dg +\n-\t\t\t\tfiltered_.total_exposure_no_dg * (1.0 - speed);\n+\t\t\tfiltered_.totalExposureNoDG =\n+\t\t\t\tspeed * target_.totalExposureNoDG +\n+\t\t\t\tfiltered_.totalExposureNoDG * (1.0 - speed);\n \t}\n \t// We can't let the no_dg exposure deviate too far below the\n \t// total exposure, as there might not be enough digital gain available\n \t// in the ISP to hide it (which will cause nasty oscillation).\n-\tif (filtered_.total_exposure_no_dg <\n-\t filtered_.total_exposure * config_.fast_reduce_threshold)\n-\t\tfiltered_.total_exposure_no_dg = filtered_.total_exposure *\n-\t\t\t\t\t\t config_.fast_reduce_threshold;\n-\tLOG(RPiAgc, Debug) << \"After filtering, total_exposure \" << filtered_.total_exposure\n-\t\t\t << \" no dg \" << filtered_.total_exposure_no_dg;\n+\tif (filtered_.totalExposureNoDG <\n+\t filtered_.totalExposure * config_.fastReduceThreshold)\n+\t\tfiltered_.totalExposureNoDG = filtered_.totalExposure * config_.fastReduceThreshold;\n+\tLOG(RPiAgc, Debug) << \"After filtering, totalExposure \" << filtered_.totalExposure\n+\t\t\t << \" no dg \" << filtered_.totalExposureNoDG;\n }\n \n void Agc::divideUpExposure()\n@@ -706,92 +690,84 @@ void Agc::divideUpExposure()\n \t// Sending the fixed shutter/gain cases through the same code may seem\n \t// unnecessary, but it will make more sense when extend this to cover\n \t// variable aperture.\n-\tDuration exposure_value = filtered_.total_exposure_no_dg;\n-\tDuration shutter_time;\n-\tdouble analogue_gain;\n-\tshutter_time = status_.fixed_shutter\n-\t\t\t ? status_.fixed_shutter\n-\t\t\t : exposure_mode_->shutter[0];\n-\tshutter_time = clipShutter(shutter_time);\n-\tanalogue_gain = status_.fixed_analogue_gain != 0.0\n-\t\t\t\t? status_.fixed_analogue_gain\n-\t\t\t\t: exposure_mode_->gain[0];\n-\tif (shutter_time * analogue_gain < exposure_value) {\n+\tDuration exposureValue = filtered_.totalExposureNoDG;\n+\tDuration shutterTime;\n+\tdouble analogueGain;\n+\tshutterTime = status_.fixedShutter ? status_.fixedShutter\n+\t\t\t\t\t : exposureMode_->shutter[0];\n+\tshutterTime = clipShutter(shutterTime);\n+\tanalogueGain = status_.fixedAnalogueGain != 0.0 ? status_.fixedAnalogueGain\n+\t\t\t\t\t\t\t: exposureMode_->gain[0];\n+\tif (shutterTime * analogueGain < exposureValue) {\n \t\tfor (unsigned int stage = 1;\n-\t\t stage < exposure_mode_->gain.size(); stage++) {\n-\t\t\tif (!status_.fixed_shutter) {\n+\t\t stage < exposureMode_->gain.size(); stage++) {\n+\t\t\tif (!status_.fixedShutter) {\n \t\t\t\tDuration stage_shutter =\n-\t\t\t\t\tclipShutter(exposure_mode_->shutter[stage]);\n-\t\t\t\tif (stage_shutter * analogue_gain >=\n-\t\t\t\t exposure_value) {\n-\t\t\t\t\tshutter_time =\n-\t\t\t\t\t\texposure_value / analogue_gain;\n+\t\t\t\t\tclipShutter(exposureMode_->shutter[stage]);\n+\t\t\t\tif (stage_shutter * analogueGain >= exposureValue) {\n+\t\t\t\t\tshutterTime = exposureValue / analogueGain;\n \t\t\t\t\tbreak;\n \t\t\t\t}\n-\t\t\t\tshutter_time = stage_shutter;\n+\t\t\t\tshutterTime = stage_shutter;\n \t\t\t}\n-\t\t\tif (status_.fixed_analogue_gain == 0.0) {\n-\t\t\t\tif (exposure_mode_->gain[stage] *\n-\t\t\t\t\t shutter_time >=\n-\t\t\t\t exposure_value) {\n-\t\t\t\t\tanalogue_gain =\n-\t\t\t\t\t\texposure_value / shutter_time;\n+\t\t\tif (status_.fixedAnalogueGain == 0.0) {\n+\t\t\t\tif (exposureMode_->gain[stage] * shutterTime >= exposureValue) {\n+\t\t\t\t\tanalogueGain = exposureValue / shutterTime;\n \t\t\t\t\tbreak;\n \t\t\t\t}\n-\t\t\t\tanalogue_gain = exposure_mode_->gain[stage];\n+\t\t\t\tanalogueGain = exposureMode_->gain[stage];\n \t\t\t}\n \t\t}\n \t}\n-\tLOG(RPiAgc, Debug) << \"Divided up shutter and gain are \" << shutter_time << \" and \"\n-\t\t\t << analogue_gain;\n+\tLOG(RPiAgc, Debug) << \"Divided up shutter and gain are \" << shutterTime << \" and \"\n+\t\t\t << analogueGain;\n \t// Finally adjust shutter time for flicker avoidance (require both\n \t// shutter and gain not to be fixed).\n-\tif (!status_.fixed_shutter && !status_.fixed_analogue_gain &&\n-\t status_.flicker_period) {\n-\t\tint flicker_periods = shutter_time / status_.flicker_period;\n-\t\tif (flicker_periods) {\n-\t\t\tDuration new_shutter_time = flicker_periods * status_.flicker_period;\n-\t\t\tanalogue_gain *= shutter_time / new_shutter_time;\n+\tif (!status_.fixedShutter && !status_.fixedAnalogueGain &&\n+\t status_.flickerPeriod) {\n+\t\tint flickerPeriods = shutterTime / status_.flickerPeriod;\n+\t\tif (flickerPeriods) {\n+\t\t\tDuration newShutterTime = flickerPeriods * status_.flickerPeriod;\n+\t\t\tanalogueGain *= shutterTime / newShutterTime;\n \t\t\t// We should still not allow the ag to go over the\n \t\t\t// largest value in the exposure mode. Note that this\n \t\t\t// may force more of the total exposure into the digital\n \t\t\t// gain as a side-effect.\n-\t\t\tanalogue_gain = std::min(analogue_gain,\n-\t\t\t\t\t\t exposure_mode_->gain.back());\n-\t\t\tshutter_time = new_shutter_time;\n+\t\t\tanalogueGain = std::min(analogueGain, exposureMode_->gain.back());\n+\t\t\tshutterTime = newShutterTime;\n \t\t}\n \t\tLOG(RPiAgc, Debug) << \"After flicker avoidance, shutter \"\n-\t\t\t\t << shutter_time << \" gain \" << analogue_gain;\n+\t\t\t\t << shutterTime << \" gain \" << analogueGain;\n \t}\n-\tfiltered_.shutter = shutter_time;\n-\tfiltered_.analogue_gain = analogue_gain;\n+\tfiltered_.shutter = shutterTime;\n+\tfiltered_.analogueGain = analogueGain;\n }\n \n-void Agc::writeAndFinish(Metadata *image_metadata, bool desaturate)\n+void Agc::writeAndFinish(Metadata *imageMetadata, bool desaturate)\n {\n-\tstatus_.total_exposure_value = filtered_.total_exposure;\n-\tstatus_.target_exposure_value = desaturate ? 0s : target_.total_exposure_no_dg;\n-\tstatus_.shutter_time = filtered_.shutter;\n-\tstatus_.analogue_gain = filtered_.analogue_gain;\n+\tstatus_.totalExposureValue = filtered_.totalExposure;\n+\tstatus_.targetExposureValue = desaturate ? 0s : target_.totalExposureNoDG;\n+\tstatus_.shutterTime = filtered_.shutter;\n+\tstatus_.analogueGain = filtered_.analogueGain;\n \t// Write to metadata as well, in case anyone wants to update the camera\n \t// immediately.\n-\timage_metadata->Set(\"agc.status\", status_);\n+\timageMetadata->set(\"agc.status\", status_);\n \tLOG(RPiAgc, Debug) << \"Output written, total exposure requested is \"\n-\t\t\t << filtered_.total_exposure;\n+\t\t\t << filtered_.totalExposure;\n \tLOG(RPiAgc, Debug) << \"Camera exposure update: shutter time \" << filtered_.shutter\n-\t\t\t << \" analogue gain \" << filtered_.analogue_gain;\n+\t\t\t << \" analogue gain \" << filtered_.analogueGain;\n }\n \n Duration Agc::clipShutter(Duration shutter)\n {\n-\tif (max_shutter_)\n-\t\tshutter = std::min(shutter, max_shutter_);\n+\tif (maxShutter_)\n+\t\tshutter = std::min(shutter, maxShutter_);\n \treturn shutter;\n }\n \n // Register algorithm with the system.\n-static Algorithm *Create(Controller *controller)\n+static Algorithm *create(Controller *controller)\n {\n \treturn (Algorithm *)new Agc(controller);\n }\n-static RegisterAlgorithm reg(NAME, &Create);\n+static RegisterAlgorithm reg(NAME, &create);\ndiff --git a/src/ipa/raspberrypi/controller/rpi/agc.hpp b/src/ipa/raspberrypi/controller/rpi/agc.hpp\nindex c100d3128c90..4ed7293bce97 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.hpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.hpp\n@@ -26,114 +26,114 @@ namespace RPiController {\n \n struct AgcMeteringMode {\n \tdouble weights[AGC_STATS_SIZE];\n-\tvoid Read(boost::property_tree::ptree const ¶ms);\n+\tvoid read(boost::property_tree::ptree const ¶ms);\n };\n \n struct AgcExposureMode {\n \tstd::vector<libcamera::utils::Duration> shutter;\n \tstd::vector<double> gain;\n-\tvoid Read(boost::property_tree::ptree const ¶ms);\n+\tvoid read(boost::property_tree::ptree const ¶ms);\n };\n \n struct AgcConstraint {\n \tenum class Bound { LOWER = 0, UPPER = 1 };\n \tBound bound;\n-\tdouble q_lo;\n-\tdouble q_hi;\n-\tPwl Y_target;\n-\tvoid Read(boost::property_tree::ptree const ¶ms);\n+\tdouble qLo;\n+\tdouble qHi;\n+\tPwl yTarget;\n+\tvoid read(boost::property_tree::ptree const ¶ms);\n };\n \n typedef std::vector<AgcConstraint> AgcConstraintMode;\n \n struct AgcConfig {\n-\tvoid Read(boost::property_tree::ptree const ¶ms);\n-\tstd::map<std::string, AgcMeteringMode> metering_modes;\n-\tstd::map<std::string, AgcExposureMode> exposure_modes;\n-\tstd::map<std::string, AgcConstraintMode> constraint_modes;\n-\tPwl Y_target;\n+\tvoid read(boost::property_tree::ptree const ¶ms);\n+\tstd::map<std::string, AgcMeteringMode> meteringModes;\n+\tstd::map<std::string, AgcExposureMode> exposureModes;\n+\tstd::map<std::string, AgcConstraintMode> constraintModes;\n+\tPwl yTarget;\n \tdouble speed;\n-\tuint16_t startup_frames;\n-\tunsigned int convergence_frames;\n-\tdouble max_change;\n-\tdouble min_change;\n-\tdouble fast_reduce_threshold;\n-\tdouble speed_up_threshold;\n-\tstd::string default_metering_mode;\n-\tstd::string default_exposure_mode;\n-\tstd::string default_constraint_mode;\n-\tdouble base_ev;\n-\tlibcamera::utils::Duration default_exposure_time;\n-\tdouble default_analogue_gain;\n+\tuint16_t startupFrames;\n+\tunsigned int convergenceFrames;\n+\tdouble maxChange;\n+\tdouble minChange;\n+\tdouble fastReduceThreshold;\n+\tdouble speedUpThreshold;\n+\tstd::string defaultMeteringMode;\n+\tstd::string defaultExposureMode;\n+\tstd::string defaultConstraintMode;\n+\tdouble baseEv;\n+\tlibcamera::utils::Duration defaultExposureTime;\n+\tdouble defaultAnalogueGain;\n };\n \n class Agc : public AgcAlgorithm\n {\n public:\n \tAgc(Controller *controller);\n-\tchar const *Name() const override;\n-\tvoid Read(boost::property_tree::ptree const ¶ms) override;\n+\tchar const *name() const override;\n+\tvoid read(boost::property_tree::ptree const ¶ms) override;\n \t// AGC handles \"pausing\" for itself.\n-\tbool IsPaused() const override;\n-\tvoid Pause() override;\n-\tvoid Resume() override;\n-\tunsigned int GetConvergenceFrames() const override;\n-\tvoid SetEv(double ev) override;\n-\tvoid SetFlickerPeriod(libcamera::utils::Duration flicker_period) override;\n-\tvoid SetMaxShutter(libcamera::utils::Duration max_shutter) override;\n-\tvoid SetFixedShutter(libcamera::utils::Duration fixed_shutter) override;\n-\tvoid SetFixedAnalogueGain(double fixed_analogue_gain) override;\n-\tvoid SetMeteringMode(std::string const &metering_mode_name) override;\n-\tvoid SetExposureMode(std::string const &exposure_mode_name) override;\n-\tvoid SetConstraintMode(std::string const &contraint_mode_name) override;\n-\tvoid SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override;\n-\tvoid Prepare(Metadata *image_metadata) override;\n-\tvoid Process(StatisticsPtr &stats, Metadata *image_metadata) override;\n+\tbool isPaused() const override;\n+\tvoid pause() override;\n+\tvoid resume() override;\n+\tunsigned int getConvergenceFrames() const override;\n+\tvoid setEv(double ev) override;\n+\tvoid setFlickerPeriod(libcamera::utils::Duration flickerPeriod) override;\n+\tvoid setMaxShutter(libcamera::utils::Duration maxShutter) override;\n+\tvoid setFixedShutter(libcamera::utils::Duration fixedShutter) override;\n+\tvoid setFixedAnalogueGain(double fixedAnalogueGain) override;\n+\tvoid setMeteringMode(std::string const &meteringModeName) override;\n+\tvoid setExposureMode(std::string const &exposureModeName) override;\n+\tvoid setConstraintMode(std::string const &contraintModeName) override;\n+\tvoid switchMode(CameraMode const &cameraMode, Metadata *metadata) override;\n+\tvoid prepare(Metadata *imageMetadata) override;\n+\tvoid process(StatisticsPtr &stats, Metadata *imageMetadata) override;\n \n private:\n-\tvoid updateLockStatus(DeviceStatus const &device_status);\n+\tvoid updateLockStatus(DeviceStatus const &deviceStatus);\n \tAgcConfig config_;\n \tvoid housekeepConfig();\n-\tvoid fetchCurrentExposure(Metadata *image_metadata);\n-\tvoid fetchAwbStatus(Metadata *image_metadata);\n-\tvoid computeGain(bcm2835_isp_stats *statistics, Metadata *image_metadata,\n-\t\t\t double &gain, double &target_Y);\n+\tvoid fetchCurrentExposure(Metadata *imageMetadata);\n+\tvoid fetchAwbStatus(Metadata *imageMetadata);\n+\tvoid computeGain(bcm2835_isp_stats *statistics, Metadata *imageMetadata,\n+\t\t\t double &gain, double &targetY);\n \tvoid computeTargetExposure(double gain);\n-\tbool applyDigitalGain(double gain, double target_Y);\n+\tbool applyDigitalGain(double gain, double targetY);\n \tvoid filterExposure(bool desaturate);\n \tvoid divideUpExposure();\n-\tvoid writeAndFinish(Metadata *image_metadata, bool desaturate);\n+\tvoid writeAndFinish(Metadata *imageMetadata, bool desaturate);\n \tlibcamera::utils::Duration clipShutter(libcamera::utils::Duration shutter);\n-\tAgcMeteringMode *metering_mode_;\n-\tAgcExposureMode *exposure_mode_;\n-\tAgcConstraintMode *constraint_mode_;\n-\tuint64_t frame_count_;\n+\tAgcMeteringMode *meteringMode_;\n+\tAgcExposureMode *exposureMode_;\n+\tAgcConstraintMode *constraintMode_;\n+\tuint64_t frameCount_;\n \tAwbStatus awb_;\n \tstruct ExposureValues {\n \t\tExposureValues();\n \n \t\tlibcamera::utils::Duration shutter;\n-\t\tdouble analogue_gain;\n-\t\tlibcamera::utils::Duration total_exposure;\n-\t\tlibcamera::utils::Duration total_exposure_no_dg; // without digital gain\n+\t\tdouble analogueGain;\n+\t\tlibcamera::utils::Duration totalExposure;\n+\t\tlibcamera::utils::Duration totalExposureNoDG; // without digital gain\n \t};\n \tExposureValues current_; // values for the current frame\n \tExposureValues target_; // calculate the values we want here\n \tExposureValues filtered_; // these values are filtered towards target\n \tAgcStatus status_;\n-\tint lock_count_;\n-\tDeviceStatus last_device_status_;\n-\tlibcamera::utils::Duration last_target_exposure_;\n-\tdouble last_sensitivity_; // sensitivity of the previous camera mode\n+\tint lockCount_;\n+\tDeviceStatus lastDeviceStatus_;\n+\tlibcamera::utils::Duration lastTargetExposure_;\n+\tdouble lastSensitivity_; // sensitivity of the previous camera mode\n \t// Below here the \"settings\" that applications can change.\n-\tstd::string metering_mode_name_;\n-\tstd::string exposure_mode_name_;\n-\tstd::string constraint_mode_name_;\n+\tstd::string meteringModeName_;\n+\tstd::string exposureModeName_;\n+\tstd::string constraintModeName_;\n \tdouble ev_;\n-\tlibcamera::utils::Duration flicker_period_;\n-\tlibcamera::utils::Duration max_shutter_;\n-\tlibcamera::utils::Duration fixed_shutter_;\n-\tdouble fixed_analogue_gain_;\n+\tlibcamera::utils::Duration flickerPeriod_;\n+\tlibcamera::utils::Duration maxShutter_;\n+\tlibcamera::utils::Duration fixedShutter_;\n+\tdouble fixedAnalogueGain_;\n };\n \n } // namespace RPiController\ndiff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp\nindex e575c14a92db..4929abc5b360 100644\n--- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp\n@@ -26,31 +26,31 @@ LOG_DEFINE_CATEGORY(RPiAlsc)\n static const int X = ALSC_CELLS_X;\n static const int Y = ALSC_CELLS_Y;\n static const int XY = X * Y;\n-static const double INSUFFICIENT_DATA = -1.0;\n+static const double InsufficientData = -1.0;\n \n Alsc::Alsc(Controller *controller)\n \t: Algorithm(controller)\n {\n-\tasync_abort_ = async_start_ = async_started_ = async_finished_ = false;\n-\tasync_thread_ = std::thread(std::bind(&Alsc::asyncFunc, this));\n+\tasyncAbort_ = asyncStart_ = asyncStarted_ = asyncFinished_ = false;\n+\tasyncThread_ = std::thread(std::bind(&Alsc::asyncFunc, this));\n }\n \n Alsc::~Alsc()\n {\n \t{\n \t\tstd::lock_guard<std::mutex> lock(mutex_);\n-\t\tasync_abort_ = true;\n+\t\tasyncAbort_ = true;\n \t}\n-\tasync_signal_.notify_one();\n-\tasync_thread_.join();\n+\tasyncSignal_.notify_one();\n+\tasyncThread_.join();\n }\n \n-char const *Alsc::Name() const\n+char const *Alsc::name() const\n {\n \treturn NAME;\n }\n \n-static void generate_lut(double *lut, boost::property_tree::ptree const ¶ms)\n+static void generateLut(double *lut, boost::property_tree::ptree const ¶ms)\n {\n \tdouble cstrength = params.get<double>(\"corner_strength\", 2.0);\n \tif (cstrength <= 1.0)\n@@ -73,34 +73,34 @@ static void generate_lut(double *lut, boost::property_tree::ptree const ¶ms)\n \t}\n }\n \n-static void read_lut(double *lut, boost::property_tree::ptree const ¶ms)\n+static void readLut(double *lut, boost::property_tree::ptree const ¶ms)\n {\n \tint num = 0;\n-\tconst int max_num = XY;\n+\tconst int maxNum = XY;\n \tfor (auto &p : params) {\n-\t\tif (num == max_num)\n+\t\tif (num == maxNum)\n \t\t\tthrow std::runtime_error(\n \t\t\t\t\"Alsc: too many entries in LSC table\");\n \t\tlut[num++] = p.second.get_value<double>();\n \t}\n-\tif (num < max_num)\n+\tif (num < maxNum)\n \t\tthrow std::runtime_error(\"Alsc: too few entries in LSC table\");\n }\n \n-static void read_calibrations(std::vector<AlscCalibration> &calibrations,\n-\t\t\t boost::property_tree::ptree const ¶ms,\n-\t\t\t std::string const &name)\n+static void readCalibrations(std::vector<AlscCalibration> &calibrations,\n+\t\t\t boost::property_tree::ptree const ¶ms,\n+\t\t\t std::string const &name)\n {\n \tif (params.get_child_optional(name)) {\n-\t\tdouble last_ct = 0;\n+\t\tdouble lastCt = 0;\n \t\tfor (auto &p : params.get_child(name)) {\n \t\t\tdouble ct = p.second.get<double>(\"ct\");\n-\t\t\tif (ct <= last_ct)\n+\t\t\tif (ct <= lastCt)\n \t\t\t\tthrow std::runtime_error(\n \t\t\t\t\t\"Alsc: entries in \" + name +\n \t\t\t\t\t\" must be in increasing ct order\");\n \t\t\tAlscCalibration calibration;\n-\t\t\tcalibration.ct = last_ct = ct;\n+\t\t\tcalibration.ct = lastCt = ct;\n \t\t\tboost::property_tree::ptree const &table =\n \t\t\t\tp.second.get_child(\"table\");\n \t\t\tint num = 0;\n@@ -124,249 +124,239 @@ static void read_calibrations(std::vector<AlscCalibration> &calibrations,\n \t}\n }\n \n-void Alsc::Read(boost::property_tree::ptree const ¶ms)\n+void Alsc::read(boost::property_tree::ptree const ¶ms)\n {\n-\tconfig_.frame_period = params.get<uint16_t>(\"frame_period\", 12);\n-\tconfig_.startup_frames = params.get<uint16_t>(\"startup_frames\", 10);\n+\tconfig_.framePeriod = params.get<uint16_t>(\"frame_period\", 12);\n+\tconfig_.startupFrames = params.get<uint16_t>(\"startup_frames\", 10);\n \tconfig_.speed = params.get<double>(\"speed\", 0.05);\n \tdouble sigma = params.get<double>(\"sigma\", 0.01);\n-\tconfig_.sigma_Cr = params.get<double>(\"sigma_Cr\", sigma);\n-\tconfig_.sigma_Cb = params.get<double>(\"sigma_Cb\", sigma);\n-\tconfig_.min_count = params.get<double>(\"min_count\", 10.0);\n-\tconfig_.min_G = params.get<uint16_t>(\"min_G\", 50);\n+\tconfig_.sigmaCr = params.get<double>(\"sigma_Cr\", sigma);\n+\tconfig_.sigmaCb = params.get<double>(\"sigma_Cb\", sigma);\n+\tconfig_.minCount = params.get<double>(\"min_count\", 10.0);\n+\tconfig_.minG = params.get<uint16_t>(\"min_G\", 50);\n \tconfig_.omega = params.get<double>(\"omega\", 1.3);\n-\tconfig_.n_iter = params.get<uint32_t>(\"n_iter\", X + Y);\n-\tconfig_.luminance_strength =\n+\tconfig_.nIter = params.get<uint32_t>(\"n_iter\", X + Y);\n+\tconfig_.luminanceStrength =\n \t\tparams.get<double>(\"luminance_strength\", 1.0);\n \tfor (int i = 0; i < XY; i++)\n-\t\tconfig_.luminance_lut[i] = 1.0;\n+\t\tconfig_.luminanceLut[i] = 1.0;\n \tif (params.get_child_optional(\"corner_strength\"))\n-\t\tgenerate_lut(config_.luminance_lut, params);\n+\t\tgenerateLut(config_.luminanceLut, params);\n \telse if (params.get_child_optional(\"luminance_lut\"))\n-\t\tread_lut(config_.luminance_lut,\n-\t\t\t params.get_child(\"luminance_lut\"));\n+\t\treadLut(config_.luminanceLut,\n+\t\t\tparams.get_child(\"luminance_lut\"));\n \telse\n \t\tLOG(RPiAlsc, Warning)\n \t\t\t<< \"no luminance table - assume unity everywhere\";\n-\tread_calibrations(config_.calibrations_Cr, params, \"calibrations_Cr\");\n-\tread_calibrations(config_.calibrations_Cb, params, \"calibrations_Cb\");\n-\tconfig_.default_ct = params.get<double>(\"default_ct\", 4500.0);\n+\treadCalibrations(config_.calibrationsCr, params, \"calibrations_Cr\");\n+\treadCalibrations(config_.calibrationsCb, params, \"calibrations_Cb\");\n+\tconfig_.defaultCt = params.get<double>(\"default_ct\", 4500.0);\n \tconfig_.threshold = params.get<double>(\"threshold\", 1e-3);\n-\tconfig_.lambda_bound = params.get<double>(\"lambda_bound\", 0.05);\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-static void resample_cal_table(double const cal_table_in[XY],\n-\t\t\t CameraMode const &camera_mode,\n-\t\t\t double cal_table_out[XY]);\n-static void compensate_lambdas_for_cal(double const cal_table[XY],\n-\t\t\t\t double const old_lambdas[XY],\n-\t\t\t\t double new_lambdas[XY]);\n-static void add_luminance_to_tables(double results[3][Y][X],\n-\t\t\t\t double const lambda_r[XY], double lambda_g,\n-\t\t\t\t double const lambda_b[XY],\n-\t\t\t\t double const luminance_lut[XY],\n-\t\t\t\t double luminance_strength);\n-\n-void Alsc::Initialise()\n-{\n-\tframe_count2_ = frame_count_ = frame_phase_ = 0;\n-\tfirst_time_ = true;\n-\tct_ = config_.default_ct;\n+\tconfig_.lambdaBound = params.get<double>(\"lambda_bound\", 0.05);\n+}\n+\n+static double getCt(Metadata *metadata, double defaultCt);\n+static void getCalTable(double ct, std::vector<AlscCalibration> const &calibrations,\n+\t\t\tdouble calTable[XY]);\n+static void resampleCalTable(double const calTableIn[XY], CameraMode const &cameraMode,\n+\t\t\t double calTableOut[XY]);\n+static void compensateLambdasForCal(double const calTable[XY], double const oldLambdas[XY],\n+\t\t\t\t double newLambdas[XY]);\n+static void addLuminanceToTables(double results[3][Y][X], double const lambdaR[XY], double lambdaG,\n+\t\t\t\t double const lambdaB[XY], double const luminanceLut[XY],\n+\t\t\t\t double luminanceStrength);\n+\n+void Alsc::initialise()\n+{\n+\tframeCount2_ = frameCount_ = framePhase_ = 0;\n+\tfirstTime_ = true;\n+\tct_ = config_.defaultCt;\n \t// The lambdas are initialised in the SwitchMode.\n }\n \n void Alsc::waitForAysncThread()\n {\n-\tif (async_started_) {\n-\t\tasync_started_ = false;\n+\tif (asyncStarted_) {\n+\t\tasyncStarted_ = false;\n \t\tstd::unique_lock<std::mutex> lock(mutex_);\n-\t\tsync_signal_.wait(lock, [&] {\n-\t\t\treturn async_finished_;\n+\t\tsyncSignal_.wait(lock, [&] {\n+\t\t\treturn asyncFinished_;\n \t\t});\n-\t\tasync_finished_ = false;\n+\t\tasyncFinished_ = false;\n \t}\n }\n \n-static bool compare_modes(CameraMode const &cm0, CameraMode const &cm1)\n+static bool compareModes(CameraMode const &cm0, CameraMode const &cm1)\n {\n \t// Return true if the modes crop from the sensor significantly differently,\n \t// or if the user transform has changed.\n \tif (cm0.transform != cm1.transform)\n \t\treturn true;\n-\tint left_diff = abs(cm0.crop_x - cm1.crop_x);\n-\tint top_diff = abs(cm0.crop_y - cm1.crop_y);\n-\tint right_diff = fabs(cm0.crop_x + cm0.scale_x * cm0.width -\n-\t\t\t cm1.crop_x - cm1.scale_x * cm1.width);\n-\tint bottom_diff = fabs(cm0.crop_y + cm0.scale_y * cm0.height -\n-\t\t\t cm1.crop_y - cm1.scale_y * cm1.height);\n+\tint leftDiff = abs(cm0.cropX - cm1.cropX);\n+\tint topDiff = abs(cm0.cropY - cm1.cropY);\n+\tint rightDiff = fabs(cm0.cropX + cm0.scaleX * cm0.width -\n+\t\t\t cm1.cropX - cm1.scaleX * cm1.width);\n+\tint bottomDiff = fabs(cm0.cropY + cm0.scaleY * cm0.height -\n+\t\t\t cm1.cropY - cm1.scaleY * cm1.height);\n \t// These thresholds are a rather arbitrary amount chosen to trigger\n \t// when carrying on with the previously calculated tables might be\n \t// worse than regenerating them (but without the adaptive algorithm).\n-\tint threshold_x = cm0.sensor_width >> 4;\n-\tint threshold_y = cm0.sensor_height >> 4;\n-\treturn left_diff > threshold_x || right_diff > threshold_x ||\n-\t top_diff > threshold_y || bottom_diff > threshold_y;\n+\tint thresholdX = cm0.sensorWidth >> 4;\n+\tint thresholdY = cm0.sensorHeight >> 4;\n+\treturn leftDiff > thresholdX || rightDiff > thresholdX ||\n+\t topDiff > thresholdY || bottomDiff > thresholdY;\n }\n \n-void Alsc::SwitchMode(CameraMode const &camera_mode,\n+void Alsc::switchMode(CameraMode const &cameraMode,\n \t\t [[maybe_unused]] Metadata *metadata)\n {\n \t// We're going to start over with the tables if there's any \"significant\"\n \t// change.\n-\tbool reset_tables = first_time_ || compare_modes(camera_mode_, camera_mode);\n+\tbool resetTables = firstTime_ || compareModes(cameraMode_, cameraMode);\n \n \t// Believe the colour temperature from the AWB, if there is one.\n-\tct_ = get_ct(metadata, ct_);\n+\tct_ = getCt(metadata, ct_);\n \n \t// Ensure the other thread isn't running while we do this.\n \twaitForAysncThread();\n \n-\tcamera_mode_ = camera_mode;\n+\tcameraMode_ = cameraMode;\n \n \t// We must resample the luminance table like we do the others, but it's\n \t// fixed so we can simply do it up front here.\n-\tresample_cal_table(config_.luminance_lut, camera_mode_, luminance_table_);\n+\tresampleCalTable(config_.luminanceLut, cameraMode_, luminanceTable_);\n \n-\tif (reset_tables) {\n+\tif (resetTables) {\n \t\t// Upon every \"table reset\", arrange for something sensible to be\n \t\t// generated. Construct the tables for the previous recorded colour\n \t\t// temperature. In order to start over from scratch we initialise\n \t\t// the lambdas, but the rest of this code then echoes the code in\n \t\t// doAlsc, without the adaptive algorithm.\n \t\tfor (int i = 0; i < XY; i++)\n-\t\t\tlambda_r_[i] = lambda_b_[i] = 1.0;\n-\t\tdouble cal_table_r[XY], cal_table_b[XY], cal_table_tmp[XY];\n-\t\tget_cal_table(ct_, config_.calibrations_Cr, cal_table_tmp);\n-\t\tresample_cal_table(cal_table_tmp, camera_mode_, cal_table_r);\n-\t\tget_cal_table(ct_, config_.calibrations_Cb, cal_table_tmp);\n-\t\tresample_cal_table(cal_table_tmp, camera_mode_, cal_table_b);\n-\t\tcompensate_lambdas_for_cal(cal_table_r, lambda_r_,\n-\t\t\t\t\t async_lambda_r_);\n-\t\tcompensate_lambdas_for_cal(cal_table_b, lambda_b_,\n-\t\t\t\t\t async_lambda_b_);\n-\t\tadd_luminance_to_tables(sync_results_, async_lambda_r_, 1.0,\n-\t\t\t\t\tasync_lambda_b_, luminance_table_,\n-\t\t\t\t\tconfig_.luminance_strength);\n-\t\tmemcpy(prev_sync_results_, sync_results_,\n-\t\t sizeof(prev_sync_results_));\n-\t\tframe_phase_ = config_.frame_period; // run the algo again asap\n-\t\tfirst_time_ = false;\n+\t\t\tlambdaR_[i] = lambdaB_[i] = 1.0;\n+\t\tdouble calTableR[XY], calTableB[XY], calTableTmp[XY];\n+\t\tgetCalTable(ct_, config_.calibrationsCr, calTableTmp);\n+\t\tresampleCalTable(calTableTmp, cameraMode_, calTableR);\n+\t\tgetCalTable(ct_, config_.calibrationsCb, calTableTmp);\n+\t\tresampleCalTable(calTableTmp, cameraMode_, calTableB);\n+\t\tcompensateLambdasForCal(calTableR, lambdaR_, asyncLambdaR_);\n+\t\tcompensateLambdasForCal(calTableB, lambdaB_, asyncLambdaB_);\n+\t\taddLuminanceToTables(syncResults_, asyncLambdaR_, 1.0, asyncLambdaB_,\n+\t\t\t\t luminanceTable_, config_.luminanceStrength);\n+\t\tmemcpy(prevSyncResults_, syncResults_, sizeof(prevSyncResults_));\n+\t\tframePhase_ = config_.framePeriod; // run the algo again asap\n+\t\tfirstTime_ = false;\n \t}\n }\n \n void Alsc::fetchAsyncResults()\n {\n \tLOG(RPiAlsc, Debug) << \"Fetch ALSC results\";\n-\tasync_finished_ = false;\n-\tasync_started_ = false;\n-\tmemcpy(sync_results_, async_results_, sizeof(sync_results_));\n+\tasyncFinished_ = false;\n+\tasyncStarted_ = false;\n+\tmemcpy(syncResults_, asyncResults_, sizeof(syncResults_));\n }\n \n-double get_ct(Metadata *metadata, double default_ct)\n+double getCt(Metadata *metadata, double defaultCt)\n {\n-\tAwbStatus awb_status;\n-\tawb_status.temperature_K = default_ct; // in case nothing found\n-\tif (metadata->Get(\"awb.status\", awb_status) != 0)\n+\tAwbStatus awbStatus;\n+\tawbStatus.temperatureK = defaultCt; // in case nothing found\n+\tif (metadata->get(\"awb.status\", awbStatus) != 0)\n \t\tLOG(RPiAlsc, Debug) << \"no AWB results found, using \"\n-\t\t\t\t << awb_status.temperature_K;\n+\t\t\t\t << awbStatus.temperatureK;\n \telse\n \t\tLOG(RPiAlsc, Debug) << \"AWB results found, using \"\n-\t\t\t\t << awb_status.temperature_K;\n-\treturn awb_status.temperature_K;\n+\t\t\t\t << awbStatus.temperatureK;\n+\treturn awbStatus.temperatureK;\n }\n \n-static void copy_stats(bcm2835_isp_stats_region regions[XY], StatisticsPtr &stats,\n-\t\t AlscStatus const &status)\n+static void copyStats(bcm2835_isp_stats_region regions[XY], StatisticsPtr &stats,\n+\t\t AlscStatus const &status)\n {\n-\tbcm2835_isp_stats_region *input_regions = stats->awb_stats;\n-\tdouble *r_table = (double *)status.r;\n-\tdouble *g_table = (double *)status.g;\n-\tdouble *b_table = (double *)status.b;\n+\tbcm2835_isp_stats_region *inputRegions = stats->awb_stats;\n+\tdouble *rTable = (double *)status.r;\n+\tdouble *gTable = (double *)status.g;\n+\tdouble *bTable = (double *)status.b;\n \tfor (int i = 0; i < XY; i++) {\n-\t\tregions[i].r_sum = input_regions[i].r_sum / r_table[i];\n-\t\tregions[i].g_sum = input_regions[i].g_sum / g_table[i];\n-\t\tregions[i].b_sum = input_regions[i].b_sum / b_table[i];\n-\t\tregions[i].counted = input_regions[i].counted;\n+\t\tregions[i].r_sum = inputRegions[i].r_sum / rTable[i];\n+\t\tregions[i].g_sum = inputRegions[i].g_sum / gTable[i];\n+\t\tregions[i].b_sum = inputRegions[i].b_sum / bTable[i];\n+\t\tregions[i].counted = inputRegions[i].counted;\n \t\t// (don't care about the uncounted value)\n \t}\n }\n \n-void Alsc::restartAsync(StatisticsPtr &stats, Metadata *image_metadata)\n+void Alsc::restartAsync(StatisticsPtr &stats, Metadata *imageMetadata)\n {\n \tLOG(RPiAlsc, Debug) << \"Starting ALSC calculation\";\n \t// Get the current colour temperature. It's all we need from the\n \t// metadata. Default to the last CT value (which could be the default).\n-\tct_ = get_ct(image_metadata, ct_);\n+\tct_ = getCt(imageMetadata, ct_);\n \t// We have to copy the statistics here, dividing out our best guess of\n \t// the LSC table that the pipeline applied to them.\n-\tAlscStatus alsc_status;\n-\tif (image_metadata->Get(\"alsc.status\", alsc_status) != 0) {\n+\tAlscStatus alscStatus;\n+\tif (imageMetadata->get(\"alsc.status\", alscStatus) != 0) {\n \t\tLOG(RPiAlsc, Warning)\n \t\t\t<< \"No ALSC status found for applied gains!\";\n \t\tfor (int y = 0; y < Y; y++)\n \t\t\tfor (int x = 0; x < X; x++) {\n-\t\t\t\talsc_status.r[y][x] = 1.0;\n-\t\t\t\talsc_status.g[y][x] = 1.0;\n-\t\t\t\talsc_status.b[y][x] = 1.0;\n+\t\t\t\talscStatus.r[y][x] = 1.0;\n+\t\t\t\talscStatus.g[y][x] = 1.0;\n+\t\t\t\talscStatus.b[y][x] = 1.0;\n \t\t\t}\n \t}\n-\tcopy_stats(statistics_, stats, alsc_status);\n-\tframe_phase_ = 0;\n-\tasync_started_ = true;\n+\tcopyStats(statistics_, stats, alscStatus);\n+\tframePhase_ = 0;\n+\tasyncStarted_ = true;\n \t{\n \t\tstd::lock_guard<std::mutex> lock(mutex_);\n-\t\tasync_start_ = true;\n+\t\tasyncStart_ = true;\n \t}\n-\tasync_signal_.notify_one();\n+\tasyncSignal_.notify_one();\n }\n \n-void Alsc::Prepare(Metadata *image_metadata)\n+void Alsc::prepare(Metadata *imageMetadata)\n {\n \t// Count frames since we started, and since we last poked the async\n \t// thread.\n-\tif (frame_count_ < (int)config_.startup_frames)\n-\t\tframe_count_++;\n-\tdouble speed = frame_count_ < (int)config_.startup_frames\n+\tif (frameCount_ < (int)config_.startupFrames)\n+\t\tframeCount_++;\n+\tdouble speed = frameCount_ < (int)config_.startupFrames\n \t\t\t ? 1.0\n \t\t\t : config_.speed;\n \tLOG(RPiAlsc, Debug)\n-\t\t<< \"frame_count \" << frame_count_ << \" speed \" << speed;\n+\t\t<< \"frame count \" << frameCount_ << \" speed \" << speed;\n \t{\n \t\tstd::unique_lock<std::mutex> lock(mutex_);\n-\t\tif (async_started_ && async_finished_)\n+\t\tif (asyncStarted_ && asyncFinished_)\n \t\t\tfetchAsyncResults();\n \t}\n \t// Apply IIR filter to results and program into the pipeline.\n-\tdouble *ptr = (double *)sync_results_,\n-\t *pptr = (double *)prev_sync_results_;\n-\tfor (unsigned int i = 0;\n-\t i < sizeof(sync_results_) / sizeof(double); i++)\n+\tdouble *ptr = (double *)syncResults_,\n+\t *pptr = (double *)prevSyncResults_;\n+\tfor (unsigned int i = 0; i < sizeof(syncResults_) / sizeof(double); i++)\n \t\tpptr[i] = speed * ptr[i] + (1.0 - speed) * pptr[i];\n \t// Put output values into status metadata.\n \tAlscStatus status;\n-\tmemcpy(status.r, prev_sync_results_[0], sizeof(status.r));\n-\tmemcpy(status.g, prev_sync_results_[1], sizeof(status.g));\n-\tmemcpy(status.b, prev_sync_results_[2], sizeof(status.b));\n-\timage_metadata->Set(\"alsc.status\", status);\n+\tmemcpy(status.r, prevSyncResults_[0], sizeof(status.r));\n+\tmemcpy(status.g, prevSyncResults_[1], sizeof(status.g));\n+\tmemcpy(status.b, prevSyncResults_[2], sizeof(status.b));\n+\timageMetadata->set(\"alsc.status\", status);\n }\n \n-void Alsc::Process(StatisticsPtr &stats, Metadata *image_metadata)\n+void Alsc::process(StatisticsPtr &stats, Metadata *imageMetadata)\n {\n \t// Count frames since we started, and since we last poked the async\n \t// thread.\n-\tif (frame_phase_ < (int)config_.frame_period)\n-\t\tframe_phase_++;\n-\tif (frame_count2_ < (int)config_.startup_frames)\n-\t\tframe_count2_++;\n-\tLOG(RPiAlsc, Debug) << \"frame_phase \" << frame_phase_;\n-\tif (frame_phase_ >= (int)config_.frame_period ||\n-\t frame_count2_ < (int)config_.startup_frames) {\n-\t\tif (async_started_ == false)\n-\t\t\trestartAsync(stats, image_metadata);\n+\tif (framePhase_ < (int)config_.framePeriod)\n+\t\tframePhase_++;\n+\tif (frameCount2_ < (int)config_.startupFrames)\n+\t\tframeCount2_++;\n+\tLOG(RPiAlsc, Debug) << \"frame_phase \" << framePhase_;\n+\tif (framePhase_ >= (int)config_.framePeriod ||\n+\t frameCount2_ < (int)config_.startupFrames) {\n+\t\tif (asyncStarted_ == false)\n+\t\t\trestartAsync(stats, imageMetadata);\n \t}\n }\n \n@@ -375,143 +365,140 @@ void Alsc::asyncFunc()\n \twhile (true) {\n \t\t{\n \t\t\tstd::unique_lock<std::mutex> lock(mutex_);\n-\t\t\tasync_signal_.wait(lock, [&] {\n-\t\t\t\treturn async_start_ || async_abort_;\n+\t\t\tasyncSignal_.wait(lock, [&] {\n+\t\t\t\treturn asyncStart_ || asyncAbort_;\n \t\t\t});\n-\t\t\tasync_start_ = false;\n-\t\t\tif (async_abort_)\n+\t\t\tasyncStart_ = false;\n+\t\t\tif (asyncAbort_)\n \t\t\t\tbreak;\n \t\t}\n \t\tdoAlsc();\n \t\t{\n \t\t\tstd::lock_guard<std::mutex> lock(mutex_);\n-\t\t\tasync_finished_ = true;\n+\t\t\tasyncFinished_ = true;\n \t\t}\n-\t\tsync_signal_.notify_one();\n+\t\tsyncSignal_.notify_one();\n \t}\n }\n \n-void get_cal_table(double ct, std::vector<AlscCalibration> const &calibrations,\n-\t\t double cal_table[XY])\n+void getCalTable(double ct, std::vector<AlscCalibration> const &calibrations,\n+\t\t double calTable[XY])\n {\n \tif (calibrations.empty()) {\n \t\tfor (int i = 0; i < XY; i++)\n-\t\t\tcal_table[i] = 1.0;\n+\t\t\tcalTable[i] = 1.0;\n \t\tLOG(RPiAlsc, Debug) << \"no calibrations found\";\n \t} else if (ct <= calibrations.front().ct) {\n-\t\tmemcpy(cal_table, calibrations.front().table,\n-\t\t XY * sizeof(double));\n+\t\tmemcpy(calTable, calibrations.front().table, XY * sizeof(double));\n \t\tLOG(RPiAlsc, Debug) << \"using calibration for \"\n \t\t\t\t << calibrations.front().ct;\n \t} else if (ct >= calibrations.back().ct) {\n-\t\tmemcpy(cal_table, calibrations.back().table,\n-\t\t XY * sizeof(double));\n+\t\tmemcpy(calTable, calibrations.back().table, XY * sizeof(double));\n \t\tLOG(RPiAlsc, Debug) << \"using calibration for \"\n \t\t\t\t << calibrations.back().ct;\n \t} else {\n \t\tint idx = 0;\n \t\twhile (ct > calibrations[idx + 1].ct)\n \t\t\tidx++;\n-\t\tdouble ct0 = calibrations[idx].ct,\n-\t\t ct1 = calibrations[idx + 1].ct;\n+\t\tdouble ct0 = calibrations[idx].ct, ct1 = calibrations[idx + 1].ct;\n \t\tLOG(RPiAlsc, Debug)\n \t\t\t<< \"ct is \" << ct << \", interpolating between \"\n \t\t\t<< ct0 << \" and \" << ct1;\n \t\tfor (int i = 0; i < XY; i++)\n-\t\t\tcal_table[i] =\n+\t\t\tcalTable[i] =\n \t\t\t\t(calibrations[idx].table[i] * (ct1 - ct) +\n \t\t\t\t calibrations[idx + 1].table[i] * (ct - ct0)) /\n \t\t\t\t(ct1 - ct0);\n \t}\n }\n \n-void resample_cal_table(double const cal_table_in[XY],\n-\t\t\tCameraMode const &camera_mode, double cal_table_out[XY])\n+void resampleCalTable(double const calTableIn[XY],\n+\t\t CameraMode const &cameraMode, double calTableOut[XY])\n {\n \t// Precalculate and cache the x sampling locations and phases to save\n \t// recomputing them on every row.\n-\tint x_lo[X], x_hi[X];\n+\tint xLo[X], xHi[X];\n \tdouble xf[X];\n-\tdouble scale_x = camera_mode.sensor_width /\n-\t\t\t (camera_mode.width * camera_mode.scale_x);\n-\tdouble x_off = camera_mode.crop_x / (double)camera_mode.sensor_width;\n-\tdouble x = .5 / scale_x + x_off * X - .5;\n-\tdouble x_inc = 1 / scale_x;\n-\tfor (int i = 0; i < X; i++, x += x_inc) {\n-\t\tx_lo[i] = floor(x);\n-\t\txf[i] = x - x_lo[i];\n-\t\tx_hi[i] = std::min(x_lo[i] + 1, X - 1);\n-\t\tx_lo[i] = std::max(x_lo[i], 0);\n-\t\tif (!!(camera_mode.transform & libcamera::Transform::HFlip)) {\n-\t\t\tx_lo[i] = X - 1 - x_lo[i];\n-\t\t\tx_hi[i] = X - 1 - x_hi[i];\n+\tdouble scaleX = cameraMode.sensorWidth /\n+\t\t\t(cameraMode.width * cameraMode.scaleX);\n+\tdouble xOff = cameraMode.cropX / (double)cameraMode.sensorWidth;\n+\tdouble x = .5 / scaleX + xOff * X - .5;\n+\tdouble xInc = 1 / scaleX;\n+\tfor (int i = 0; i < X; i++, x += xInc) {\n+\t\txLo[i] = floor(x);\n+\t\txf[i] = x - xLo[i];\n+\t\txHi[i] = std::min(xLo[i] + 1, X - 1);\n+\t\txLo[i] = std::max(xLo[i], 0);\n+\t\tif (!!(cameraMode.transform & libcamera::Transform::HFlip)) {\n+\t\t\txLo[i] = X - 1 - xLo[i];\n+\t\t\txHi[i] = X - 1 - xHi[i];\n \t\t}\n \t}\n \t// Now march over the output table generating the new values.\n-\tdouble scale_y = camera_mode.sensor_height /\n-\t\t\t (camera_mode.height * camera_mode.scale_y);\n-\tdouble y_off = camera_mode.crop_y / (double)camera_mode.sensor_height;\n-\tdouble y = .5 / scale_y + y_off * Y - .5;\n-\tdouble y_inc = 1 / scale_y;\n-\tfor (int j = 0; j < Y; j++, y += y_inc) {\n-\t\tint y_lo = floor(y);\n-\t\tdouble yf = y - y_lo;\n-\t\tint y_hi = std::min(y_lo + 1, Y - 1);\n-\t\ty_lo = std::max(y_lo, 0);\n-\t\tif (!!(camera_mode.transform & libcamera::Transform::VFlip)) {\n-\t\t\ty_lo = Y - 1 - y_lo;\n-\t\t\ty_hi = Y - 1 - y_hi;\n+\tdouble scaleY = cameraMode.sensorHeight /\n+\t\t\t(cameraMode.height * cameraMode.scaleY);\n+\tdouble yOff = cameraMode.cropY / (double)cameraMode.sensorHeight;\n+\tdouble y = .5 / scaleY + yOff * Y - .5;\n+\tdouble yInc = 1 / scaleY;\n+\tfor (int j = 0; j < Y; j++, y += yInc) {\n+\t\tint yLo = floor(y);\n+\t\tdouble yf = y - yLo;\n+\t\tint yHi = std::min(yLo + 1, Y - 1);\n+\t\tyLo = std::max(yLo, 0);\n+\t\tif (!!(cameraMode.transform & libcamera::Transform::VFlip)) {\n+\t\t\tyLo = Y - 1 - yLo;\n+\t\t\tyHi = Y - 1 - yHi;\n \t\t}\n-\t\tdouble const *row_above = cal_table_in + X * y_lo;\n-\t\tdouble const *row_below = cal_table_in + X * y_hi;\n+\t\tdouble const *rowAbove = calTableIn + X * yLo;\n+\t\tdouble const *rowBelow = calTableIn + X * yHi;\n \t\tfor (int i = 0; i < X; i++) {\n-\t\t\tdouble above = row_above[x_lo[i]] * (1 - xf[i]) +\n-\t\t\t\t row_above[x_hi[i]] * xf[i];\n-\t\t\tdouble below = row_below[x_lo[i]] * (1 - xf[i]) +\n-\t\t\t\t row_below[x_hi[i]] * xf[i];\n-\t\t\t*(cal_table_out++) = above * (1 - yf) + below * yf;\n+\t\t\tdouble above = rowAbove[xLo[i]] * (1 - xf[i]) +\n+\t\t\t\t rowAbove[xHi[i]] * xf[i];\n+\t\t\tdouble below = rowBelow[xLo[i]] * (1 - xf[i]) +\n+\t\t\t\t rowBelow[xHi[i]] * xf[i];\n+\t\t\t*(calTableOut++) = above * (1 - yf) + below * yf;\n \t\t}\n \t}\n }\n \n // Calculate chrominance statistics (R/G and B/G) for each region.\n static_assert(XY == AWB_REGIONS, \"ALSC/AWB statistics region mismatch\");\n-static void calculate_Cr_Cb(bcm2835_isp_stats_region *awb_region, double Cr[XY],\n-\t\t\t double Cb[XY], uint32_t min_count, uint16_t min_G)\n+static void calculateCrCb(bcm2835_isp_stats_region *awbRegion, double cr[XY],\n+\t\t\t double cb[XY], uint32_t minCount, uint16_t minG)\n {\n \tfor (int i = 0; i < XY; i++) {\n-\t\tbcm2835_isp_stats_region &zone = awb_region[i];\n-\t\tif (zone.counted <= min_count ||\n-\t\t zone.g_sum / zone.counted <= min_G) {\n-\t\t\tCr[i] = Cb[i] = INSUFFICIENT_DATA;\n+\t\tbcm2835_isp_stats_region &zone = awbRegion[i];\n+\t\tif (zone.counted <= minCount ||\n+\t\t zone.g_sum / zone.counted <= minG) {\n+\t\t\tcr[i] = cb[i] = InsufficientData;\n \t\t\tcontinue;\n \t\t}\n-\t\tCr[i] = zone.r_sum / (double)zone.g_sum;\n-\t\tCb[i] = zone.b_sum / (double)zone.g_sum;\n+\t\tcr[i] = zone.r_sum / (double)zone.g_sum;\n+\t\tcb[i] = zone.b_sum / (double)zone.g_sum;\n \t}\n }\n \n-static void apply_cal_table(double const cal_table[XY], double C[XY])\n+static void applyCalTable(double const calTable[XY], double C[XY])\n {\n \tfor (int i = 0; i < XY; i++)\n-\t\tif (C[i] != INSUFFICIENT_DATA)\n-\t\t\tC[i] *= cal_table[i];\n+\t\tif (C[i] != InsufficientData)\n+\t\t\tC[i] *= calTable[i];\n }\n \n-void compensate_lambdas_for_cal(double const cal_table[XY],\n-\t\t\t\tdouble const old_lambdas[XY],\n-\t\t\t\tdouble new_lambdas[XY])\n+void compensateLambdasForCal(double const calTable[XY],\n+\t\t\t double const oldLambdas[XY],\n+\t\t\t double newLambdas[XY])\n {\n-\tdouble min_new_lambda = std::numeric_limits<double>::max();\n+\tdouble minNewLambda = std::numeric_limits<double>::max();\n \tfor (int i = 0; i < XY; i++) {\n-\t\tnew_lambdas[i] = old_lambdas[i] * cal_table[i];\n-\t\tmin_new_lambda = std::min(min_new_lambda, new_lambdas[i]);\n+\t\tnewLambdas[i] = oldLambdas[i] * calTable[i];\n+\t\tminNewLambda = std::min(minNewLambda, newLambdas[i]);\n \t}\n \tfor (int i = 0; i < XY; i++)\n-\t\tnew_lambdas[i] /= min_new_lambda;\n+\t\tnewLambdas[i] /= minNewLambda;\n }\n \n-[[maybe_unused]] static void print_cal_table(double const C[XY])\n+[[maybe_unused]] static void printCalTable(double const C[XY])\n {\n \tprintf(\"table: [\\n\");\n \tfor (int j = 0; j < Y; j++) {\n@@ -527,31 +514,29 @@ void compensate_lambdas_for_cal(double const cal_table[XY],\n \n // Compute weight out of 1.0 which reflects how similar we wish to make the\n // colours of these two regions.\n-static double compute_weight(double C_i, double C_j, double sigma)\n+static double computeWeight(double Ci, double Cj, double sigma)\n {\n-\tif (C_i == INSUFFICIENT_DATA || C_j == INSUFFICIENT_DATA)\n+\tif (Ci == InsufficientData || Cj == InsufficientData)\n \t\treturn 0;\n-\tdouble diff = (C_i - C_j) / sigma;\n+\tdouble diff = (Ci - Cj) / sigma;\n \treturn exp(-diff * diff / 2);\n }\n \n // Compute all weights.\n-static void compute_W(double const C[XY], double sigma, double W[XY][4])\n+static void computeW(double const C[XY], double sigma, double W[XY][4])\n {\n \tfor (int i = 0; i < XY; i++) {\n \t\t// Start with neighbour above and go clockwise.\n-\t\tW[i][0] = i >= X ? compute_weight(C[i], C[i - X], sigma) : 0;\n-\t\tW[i][1] = i % X < X - 1 ? compute_weight(C[i], C[i + 1], sigma)\n-\t\t\t\t\t: 0;\n-\t\tW[i][2] =\n-\t\t\ti < XY - X ? compute_weight(C[i], C[i + X], sigma) : 0;\n-\t\tW[i][3] = i % X ? compute_weight(C[i], C[i - 1], sigma) : 0;\n+\t\tW[i][0] = i >= X ? computeWeight(C[i], C[i - X], sigma) : 0;\n+\t\tW[i][1] = i % X < X - 1 ? computeWeight(C[i], C[i + 1], sigma) : 0;\n+\t\tW[i][2] = i < XY - X ? computeWeight(C[i], C[i + X], sigma) : 0;\n+\t\tW[i][3] = i % X ? computeWeight(C[i], C[i - 1], sigma) : 0;\n \t}\n }\n \n // Compute M, the large but sparse matrix such that M * lambdas = 0.\n-static void construct_M(double const C[XY], double const W[XY][4],\n-\t\t\tdouble M[XY][4])\n+static void constructM(double const C[XY], double const W[XY][4],\n+\t\t double M[XY][4])\n {\n \tdouble epsilon = 0.001;\n \tfor (int i = 0; i < XY; i++) {\n@@ -560,108 +545,96 @@ static void construct_M(double const C[XY], double const W[XY][4],\n \t\tint m = !!(i >= X) + !!(i % X < X - 1) + !!(i < XY - X) +\n \t\t\t!!(i % X); // total number of neighbours\n \t\t// we'll divide the diagonal out straight away\n-\t\tdouble diagonal =\n-\t\t\t(epsilon + W[i][0] + W[i][1] + W[i][2] + W[i][3]) *\n-\t\t\tC[i];\n-\t\tM[i][0] = i >= X ? (W[i][0] * C[i - X] + epsilon / m * C[i]) /\n-\t\t\t\t\t diagonal\n-\t\t\t\t : 0;\n-\t\tM[i][1] = i % X < X - 1\n-\t\t\t\t ? (W[i][1] * C[i + 1] + epsilon / m * C[i]) /\n-\t\t\t\t\t diagonal\n-\t\t\t\t : 0;\n-\t\tM[i][2] = i < XY - X\n-\t\t\t\t ? (W[i][2] * C[i + X] + epsilon / m * C[i]) /\n-\t\t\t\t\t diagonal\n-\t\t\t\t : 0;\n-\t\tM[i][3] = i % X ? (W[i][3] * C[i - 1] + epsilon / m * C[i]) /\n-\t\t\t\t\t diagonal\n-\t\t\t\t: 0;\n+\t\tdouble diagonal = (epsilon + W[i][0] + W[i][1] + W[i][2] + W[i][3]) * C[i];\n+\t\tM[i][0] = i >= X ? (W[i][0] * C[i - X] + epsilon / m * C[i]) / diagonal : 0;\n+\t\tM[i][1] = i % X < X - 1 ? (W[i][1] * C[i + 1] + epsilon / m * C[i]) / diagonal : 0;\n+\t\tM[i][2] = i < XY - X ? (W[i][2] * C[i + X] + epsilon / m * C[i]) / diagonal : 0;\n+\t\tM[i][3] = i % X ? (W[i][3] * C[i - 1] + epsilon / m * C[i]) / diagonal : 0;\n \t}\n }\n \n // In the compute_lambda_ functions, note that the matrix coefficients for the\n // left/right neighbours are zero down the left/right edges, so we don't need\n // need to test the i value to exclude them.\n-static double compute_lambda_bottom(int i, double const M[XY][4],\n-\t\t\t\t double lambda[XY])\n+static double computeLambdaBottom(int i, double const M[XY][4],\n+\t\t\t\t double lambda[XY])\n {\n \treturn M[i][1] * lambda[i + 1] + M[i][2] * lambda[i + X] +\n \t M[i][3] * lambda[i - 1];\n }\n-static double compute_lambda_bottom_start(int i, double const M[XY][4],\n-\t\t\t\t\t double lambda[XY])\n+static double computeLambdaBottomStart(int i, double const M[XY][4],\n+\t\t\t\t double lambda[XY])\n {\n \treturn M[i][1] * lambda[i + 1] + M[i][2] * lambda[i + X];\n }\n-static double compute_lambda_interior(int i, double const M[XY][4],\n-\t\t\t\t double lambda[XY])\n+static double computeLambdaInterior(int i, double const M[XY][4],\n+\t\t\t\t double lambda[XY])\n {\n \treturn M[i][0] * lambda[i - X] + M[i][1] * lambda[i + 1] +\n \t M[i][2] * lambda[i + X] + M[i][3] * lambda[i - 1];\n }\n-static double compute_lambda_top(int i, double const M[XY][4],\n-\t\t\t\t double lambda[XY])\n+static double computeLambdaTop(int i, double const M[XY][4],\n+\t\t\t double lambda[XY])\n {\n \treturn M[i][0] * lambda[i - X] + M[i][1] * lambda[i + 1] +\n \t M[i][3] * lambda[i - 1];\n }\n-static double compute_lambda_top_end(int i, double const M[XY][4],\n-\t\t\t\t double lambda[XY])\n+static double computeLambdaTopEnd(int i, double const M[XY][4],\n+\t\t\t\t double lambda[XY])\n {\n \treturn M[i][0] * lambda[i - X] + M[i][3] * lambda[i - 1];\n }\n \n // Gauss-Seidel iteration with over-relaxation.\n-static double gauss_seidel2_SOR(double const M[XY][4], double omega,\n-\t\t\t\tdouble lambda[XY], double lambda_bound)\n+static double gaussSeidel2Sor(double const M[XY][4], double omega,\n+\t\t\t double lambda[XY], double lambdaBound)\n {\n-\tconst double min = 1 - lambda_bound, max = 1 + lambda_bound;\n-\tdouble old_lambda[XY];\n+\tconst double min = 1 - lambdaBound, max = 1 + lambdaBound;\n+\tdouble oldLambda[XY];\n \tint i;\n \tfor (i = 0; i < XY; i++)\n-\t\told_lambda[i] = lambda[i];\n-\tlambda[0] = compute_lambda_bottom_start(0, M, lambda);\n+\t\toldLambda[i] = lambda[i];\n+\tlambda[0] = computeLambdaBottomStart(0, M, lambda);\n \tlambda[0] = std::clamp(lambda[0], min, max);\n \tfor (i = 1; i < X; i++) {\n-\t\tlambda[i] = compute_lambda_bottom(i, M, lambda);\n+\t\tlambda[i] = computeLambdaBottom(i, M, lambda);\n \t\tlambda[i] = std::clamp(lambda[i], min, max);\n \t}\n \tfor (; i < XY - X; i++) {\n-\t\tlambda[i] = compute_lambda_interior(i, M, lambda);\n+\t\tlambda[i] = computeLambdaInterior(i, M, lambda);\n \t\tlambda[i] = std::clamp(lambda[i], min, max);\n \t}\n \tfor (; i < XY - 1; i++) {\n-\t\tlambda[i] = compute_lambda_top(i, M, lambda);\n+\t\tlambda[i] = computeLambdaTop(i, M, lambda);\n \t\tlambda[i] = std::clamp(lambda[i], min, max);\n \t}\n-\tlambda[i] = compute_lambda_top_end(i, M, lambda);\n+\tlambda[i] = computeLambdaTopEnd(i, M, lambda);\n \tlambda[i] = std::clamp(lambda[i], min, max);\n \t// Also solve the system from bottom to top, to help spread the updates\n \t// better.\n-\tlambda[i] = compute_lambda_top_end(i, M, lambda);\n+\tlambda[i] = computeLambdaTopEnd(i, M, lambda);\n \tlambda[i] = std::clamp(lambda[i], min, max);\n \tfor (i = XY - 2; i >= XY - X; i--) {\n-\t\tlambda[i] = compute_lambda_top(i, M, lambda);\n+\t\tlambda[i] = computeLambdaTop(i, M, lambda);\n \t\tlambda[i] = std::clamp(lambda[i], min, max);\n \t}\n \tfor (; i >= X; i--) {\n-\t\tlambda[i] = compute_lambda_interior(i, M, lambda);\n+\t\tlambda[i] = computeLambdaInterior(i, M, lambda);\n \t\tlambda[i] = std::clamp(lambda[i], min, max);\n \t}\n \tfor (; i >= 1; i--) {\n-\t\tlambda[i] = compute_lambda_bottom(i, M, lambda);\n+\t\tlambda[i] = computeLambdaBottom(i, M, lambda);\n \t\tlambda[i] = std::clamp(lambda[i], min, max);\n \t}\n-\tlambda[0] = compute_lambda_bottom_start(0, M, lambda);\n+\tlambda[0] = computeLambdaBottomStart(0, M, lambda);\n \tlambda[0] = std::clamp(lambda[0], min, max);\n-\tdouble max_diff = 0;\n+\tdouble maxDiff = 0;\n \tfor (i = 0; i < XY; i++) {\n-\t\tlambda[i] = old_lambda[i] + (lambda[i] - old_lambda[i]) * omega;\n-\t\tif (fabs(lambda[i] - old_lambda[i]) > fabs(max_diff))\n-\t\t\tmax_diff = lambda[i] - old_lambda[i];\n+\t\tlambda[i] = oldLambda[i] + (lambda[i] - oldLambda[i]) * omega;\n+\t\tif (fabs(lambda[i] - oldLambda[i]) > fabs(maxDiff))\n+\t\t\tmaxDiff = lambda[i] - oldLambda[i];\n \t}\n-\treturn max_diff;\n+\treturn maxDiff;\n }\n \n // Normalise the values so that the smallest value is 1.\n@@ -683,105 +656,99 @@ static void reaverage(Span<double> data)\n \t\td *= ratio;\n }\n \n-static void run_matrix_iterations(double const C[XY], double lambda[XY],\n-\t\t\t\t double const W[XY][4], double omega,\n-\t\t\t\t int n_iter, double threshold, double lambda_bound)\n+static void runMatrixIterations(double const C[XY], double lambda[XY],\n+\t\t\t\tdouble const W[XY][4], double omega,\n+\t\t\t\tint nIter, double threshold, double lambdaBound)\n {\n \tdouble M[XY][4];\n-\tconstruct_M(C, W, M);\n-\tdouble last_max_diff = std::numeric_limits<double>::max();\n-\tfor (int i = 0; i < n_iter; i++) {\n-\t\tdouble max_diff = fabs(gauss_seidel2_SOR(M, omega, lambda, lambda_bound));\n-\t\tif (max_diff < threshold) {\n+\tconstructM(C, W, M);\n+\tdouble lastMaxDiff = std::numeric_limits<double>::max();\n+\tfor (int i = 0; i < nIter; i++) {\n+\t\tdouble maxDiff = fabs(gaussSeidel2Sor(M, omega, lambda, lambdaBound));\n+\t\tif (maxDiff < threshold) {\n \t\t\tLOG(RPiAlsc, Debug)\n \t\t\t\t<< \"Stop after \" << i + 1 << \" iterations\";\n \t\t\tbreak;\n \t\t}\n \t\t// this happens very occasionally (so make a note), though\n \t\t// doesn't seem to matter\n-\t\tif (max_diff > last_max_diff)\n+\t\tif (maxDiff > lastMaxDiff)\n \t\t\tLOG(RPiAlsc, Debug)\n \t\t\t\t<< \"Iteration \" << i << \": max_diff gone up \"\n-\t\t\t\t<< last_max_diff << \" to \" << max_diff;\n-\t\tlast_max_diff = max_diff;\n+\t\t\t\t<< lastMaxDiff << \" to \" << maxDiff;\n+\t\tlastMaxDiff = maxDiff;\n \t}\n \t// We're going to normalise the lambdas so the total average is 1.\n \treaverage({ lambda, XY });\n }\n \n-static void add_luminance_rb(double result[XY], double const lambda[XY],\n-\t\t\t double const luminance_lut[XY],\n-\t\t\t double luminance_strength)\n+static void addLuminanceRb(double result[XY], double const lambda[XY],\n+\t\t\t double const luminanceLut[XY],\n+\t\t\t double luminanceStrength)\n {\n \tfor (int i = 0; i < XY; i++)\n-\t\tresult[i] = lambda[i] *\n-\t\t\t ((luminance_lut[i] - 1) * luminance_strength + 1);\n+\t\tresult[i] = lambda[i] * ((luminanceLut[i] - 1) * luminanceStrength + 1);\n }\n \n-static void add_luminance_g(double result[XY], double lambda,\n-\t\t\t double const luminance_lut[XY],\n-\t\t\t double luminance_strength)\n+static void addLuminanceG(double result[XY], double lambda,\n+\t\t\t double const luminanceLut[XY],\n+\t\t\t double luminanceStrength)\n {\n \tfor (int i = 0; i < XY; i++)\n-\t\tresult[i] = lambda *\n-\t\t\t ((luminance_lut[i] - 1) * luminance_strength + 1);\n+\t\tresult[i] = lambda * ((luminanceLut[i] - 1) * luminanceStrength + 1);\n }\n \n-void add_luminance_to_tables(double results[3][Y][X], double const lambda_r[XY],\n-\t\t\t double lambda_g, double const lambda_b[XY],\n-\t\t\t double const luminance_lut[XY],\n-\t\t\t double luminance_strength)\n+void addLuminanceToTables(double results[3][Y][X], double const lambdaR[XY],\n+\t\t\t double lambdaG, double const lambdaB[XY],\n+\t\t\t double const luminanceLut[XY],\n+\t\t\t double luminanceStrength)\n {\n-\tadd_luminance_rb((double *)results[0], lambda_r, luminance_lut,\n-\t\t\t luminance_strength);\n-\tadd_luminance_g((double *)results[1], lambda_g, luminance_lut,\n-\t\t\tluminance_strength);\n-\tadd_luminance_rb((double *)results[2], lambda_b, luminance_lut,\n-\t\t\t luminance_strength);\n+\taddLuminanceRb((double *)results[0], lambdaR, luminanceLut, luminanceStrength);\n+\taddLuminanceG((double *)results[1], lambdaG, luminanceLut, luminanceStrength);\n+\taddLuminanceRb((double *)results[2], lambdaB, luminanceLut, luminanceStrength);\n \tnormalise((double *)results, 3 * XY);\n }\n \n void Alsc::doAlsc()\n {\n-\tdouble Cr[XY], Cb[XY], Wr[XY][4], Wb[XY][4], cal_table_r[XY],\n-\t\tcal_table_b[XY], cal_table_tmp[XY];\n+\tdouble cr[XY], cb[XY], wr[XY][4], wb[XY][4], calTableR[XY], calTableB[XY], calTableTmp[XY];\n \t// Calculate our R/B (\"Cr\"/\"Cb\") colour statistics, and assess which are\n \t// usable.\n-\tcalculate_Cr_Cb(statistics_, Cr, Cb, config_.min_count, config_.min_G);\n+\tcalculateCrCb(statistics_, cr, cb, config_.minCount, config_.minG);\n \t// Fetch the new calibrations (if any) for this CT. Resample them in\n \t// case the camera mode is not full-frame.\n-\tget_cal_table(ct_, config_.calibrations_Cr, cal_table_tmp);\n-\tresample_cal_table(cal_table_tmp, camera_mode_, cal_table_r);\n-\tget_cal_table(ct_, config_.calibrations_Cb, cal_table_tmp);\n-\tresample_cal_table(cal_table_tmp, camera_mode_, cal_table_b);\n+\tgetCalTable(ct_, config_.calibrationsCr, calTableTmp);\n+\tresampleCalTable(calTableTmp, cameraMode_, calTableR);\n+\tgetCalTable(ct_, config_.calibrationsCb, calTableTmp);\n+\tresampleCalTable(calTableTmp, cameraMode_, calTableB);\n \t// You could print out the cal tables for this image here, if you're\n \t// tuning the algorithm...\n \t// Apply any calibration to the statistics, so the adaptive algorithm\n \t// makes only the extra adjustments.\n-\tapply_cal_table(cal_table_r, Cr);\n-\tapply_cal_table(cal_table_b, Cb);\n+\tapplyCalTable(calTableR, cr);\n+\tapplyCalTable(calTableB, cb);\n \t// Compute weights between zones.\n-\tcompute_W(Cr, config_.sigma_Cr, Wr);\n-\tcompute_W(Cb, config_.sigma_Cb, Wb);\n+\tcomputeW(cr, config_.sigmaCr, wr);\n+\tcomputeW(cb, config_.sigmaCb, wb);\n \t// Run Gauss-Seidel iterations over the resulting matrix, for R and B.\n-\trun_matrix_iterations(Cr, lambda_r_, Wr, config_.omega, config_.n_iter,\n-\t\t\t config_.threshold, config_.lambda_bound);\n-\trun_matrix_iterations(Cb, lambda_b_, Wb, config_.omega, config_.n_iter,\n-\t\t\t config_.threshold, config_.lambda_bound);\n+\trunMatrixIterations(cr, lambdaR_, wr, config_.omega, config_.nIter,\n+\t\t\t config_.threshold, config_.lambdaBound);\n+\trunMatrixIterations(cb, lambdaB_, wb, config_.omega, config_.nIter,\n+\t\t\t config_.threshold, config_.lambdaBound);\n \t// Fold the calibrated gains into our final lambda values. (Note that on\n \t// the next run, we re-start with the lambda values that don't have the\n \t// calibration gains included.)\n-\tcompensate_lambdas_for_cal(cal_table_r, lambda_r_, async_lambda_r_);\n-\tcompensate_lambdas_for_cal(cal_table_b, lambda_b_, async_lambda_b_);\n+\tcompensateLambdasForCal(calTableR, lambdaR_, asyncLambdaR_);\n+\tcompensateLambdasForCal(calTableB, lambdaB_, asyncLambdaB_);\n \t// Fold in the luminance table at the appropriate strength.\n-\tadd_luminance_to_tables(async_results_, async_lambda_r_, 1.0,\n-\t\t\t\tasync_lambda_b_, luminance_table_,\n-\t\t\t\tconfig_.luminance_strength);\n+\taddLuminanceToTables(asyncResults_, asyncLambdaR_, 1.0,\n+\t\t\t asyncLambdaB_, luminanceTable_,\n+\t\t\t config_.luminanceStrength);\n }\n \n // Register algorithm with the system.\n-static Algorithm *Create(Controller *controller)\n+static Algorithm *create(Controller *controller)\n {\n \treturn (Algorithm *)new Alsc(controller);\n }\n-static RegisterAlgorithm reg(NAME, &Create);\n+static RegisterAlgorithm reg(NAME, &create);\ndiff --git a/src/ipa/raspberrypi/controller/rpi/alsc.hpp b/src/ipa/raspberrypi/controller/rpi/alsc.hpp\nindex d1dbe0d1d22d..7a0949d1ccc5 100644\n--- a/src/ipa/raspberrypi/controller/rpi/alsc.hpp\n+++ b/src/ipa/raspberrypi/controller/rpi/alsc.hpp\n@@ -24,24 +24,24 @@ struct AlscCalibration {\n \n struct AlscConfig {\n \t// Only repeat the ALSC calculation every \"this many\" frames\n-\tuint16_t frame_period;\n+\tuint16_t framePeriod;\n \t// number of initial frames for which speed taken as 1.0 (maximum)\n-\tuint16_t startup_frames;\n+\tuint16_t startupFrames;\n \t// IIR filter speed applied to algorithm results\n \tdouble speed;\n-\tdouble sigma_Cr;\n-\tdouble sigma_Cb;\n-\tdouble min_count;\n-\tuint16_t min_G;\n+\tdouble sigmaCr;\n+\tdouble sigmaCb;\n+\tdouble minCount;\n+\tuint16_t minG;\n \tdouble omega;\n-\tuint32_t n_iter;\n-\tdouble luminance_lut[ALSC_CELLS_X * ALSC_CELLS_Y];\n-\tdouble luminance_strength;\n-\tstd::vector<AlscCalibration> calibrations_Cr;\n-\tstd::vector<AlscCalibration> calibrations_Cb;\n-\tdouble default_ct; // colour temperature if no metadata found\n+\tuint32_t nIter;\n+\tdouble luminanceLut[ALSC_CELLS_X * ALSC_CELLS_Y];\n+\tdouble luminanceStrength;\n+\tstd::vector<AlscCalibration> calibrationsCr;\n+\tstd::vector<AlscCalibration> calibrationsCb;\n+\tdouble defaultCt; // colour temperature if no metadata found\n \tdouble threshold; // iteration termination threshold\n-\tdouble lambda_bound; // upper/lower bound for lambda from a value of 1\n+\tdouble lambdaBound; // upper/lower bound for lambda from a value of 1\n };\n \n class Alsc : public Algorithm\n@@ -49,58 +49,58 @@ class Alsc : public Algorithm\n public:\n \tAlsc(Controller *controller = NULL);\n \t~Alsc();\n-\tchar const *Name() const override;\n-\tvoid Initialise() override;\n-\tvoid SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override;\n-\tvoid Read(boost::property_tree::ptree const ¶ms) override;\n-\tvoid Prepare(Metadata *image_metadata) override;\n-\tvoid Process(StatisticsPtr &stats, Metadata *image_metadata) override;\n+\tchar const *name() const override;\n+\tvoid initialise() override;\n+\tvoid switchMode(CameraMode const &cameraMode, Metadata *metadata) override;\n+\tvoid read(boost::property_tree::ptree const ¶ms) override;\n+\tvoid prepare(Metadata *imageMetadata) override;\n+\tvoid process(StatisticsPtr &stats, Metadata *imageMetadata) override;\n \n private:\n \t// configuration is read-only, and available to both threads\n \tAlscConfig config_;\n-\tbool first_time_;\n-\tCameraMode camera_mode_;\n-\tdouble luminance_table_[ALSC_CELLS_X * ALSC_CELLS_Y];\n-\tstd::thread async_thread_;\n+\tbool firstTime_;\n+\tCameraMode cameraMode_;\n+\tdouble luminanceTable_[ALSC_CELLS_X * ALSC_CELLS_Y];\n+\tstd::thread asyncThread_;\n \tvoid asyncFunc(); // asynchronous thread function\n \tstd::mutex mutex_;\n \t// condvar for async thread to wait on\n-\tstd::condition_variable async_signal_;\n+\tstd::condition_variable asyncSignal_;\n \t// condvar for synchronous thread to wait on\n-\tstd::condition_variable sync_signal_;\n+\tstd::condition_variable syncSignal_;\n \t// for sync thread to check if async thread finished (requires mutex)\n-\tbool async_finished_;\n+\tbool asyncFinished_;\n \t// for async thread to check if it's been told to run (requires mutex)\n-\tbool async_start_;\n+\tbool asyncStart_;\n \t// for async thread to check if it's been told to quit (requires mutex)\n-\tbool async_abort_;\n+\tbool asyncAbort_;\n \n \t// The following are only for the synchronous thread to use:\n \t// for sync thread to note its has asked async thread to run\n-\tbool async_started_;\n-\t// counts up to frame_period before restarting the async thread\n-\tint frame_phase_;\n-\t// counts up to startup_frames\n-\tint frame_count_;\n-\t// counts up to startup_frames for Process function\n-\tint frame_count2_;\n-\tdouble sync_results_[3][ALSC_CELLS_Y][ALSC_CELLS_X];\n-\tdouble prev_sync_results_[3][ALSC_CELLS_Y][ALSC_CELLS_X];\n+\tbool asyncStarted_;\n+\t// counts up to framePeriod before restarting the async thread\n+\tint framePhase_;\n+\t// counts up to startupFrames\n+\tint frameCount_;\n+\t// counts up to startupFrames for Process function\n+\tint frameCount2_;\n+\tdouble syncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X];\n+\tdouble prevSyncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X];\n \tvoid waitForAysncThread();\n \t// The following are for the asynchronous thread to use, though the main\n \t// thread can set/reset them if the async thread is known to be idle:\n-\tvoid restartAsync(StatisticsPtr &stats, Metadata *image_metadata);\n+\tvoid restartAsync(StatisticsPtr &stats, Metadata *imageMetadata);\n \t// copy out the results from the async thread so that it can be restarted\n \tvoid fetchAsyncResults();\n \tdouble ct_;\n \tbcm2835_isp_stats_region statistics_[ALSC_CELLS_Y * ALSC_CELLS_X];\n-\tdouble async_results_[3][ALSC_CELLS_Y][ALSC_CELLS_X];\n-\tdouble async_lambda_r_[ALSC_CELLS_X * ALSC_CELLS_Y];\n-\tdouble async_lambda_b_[ALSC_CELLS_X * ALSC_CELLS_Y];\n+\tdouble asyncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X];\n+\tdouble asyncLambdaR_[ALSC_CELLS_X * ALSC_CELLS_Y];\n+\tdouble asyncLambdaB_[ALSC_CELLS_X * ALSC_CELLS_Y];\n \tvoid doAlsc();\n-\tdouble lambda_r_[ALSC_CELLS_X * ALSC_CELLS_Y];\n-\tdouble lambda_b_[ALSC_CELLS_X * ALSC_CELLS_Y];\n+\tdouble lambdaR_[ALSC_CELLS_X * ALSC_CELLS_Y];\n+\tdouble lambdaB_[ALSC_CELLS_X * ALSC_CELLS_Y];\n };\n \n } // namespace RPiController\ndiff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp\nindex d4c934473832..74449c8c7591 100644\n--- a/src/ipa/raspberrypi/controller/rpi/awb.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp\n@@ -24,33 +24,33 @@ LOG_DEFINE_CATEGORY(RPiAwb)\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 ¶ms)\n+void AwbMode::read(boost::property_tree::ptree const ¶ms)\n {\n-\tct_lo = params.get<double>(\"lo\");\n-\tct_hi = params.get<double>(\"hi\");\n+\tctLo = params.get<double>(\"lo\");\n+\tctHi = params.get<double>(\"hi\");\n }\n \n-void AwbPrior::Read(boost::property_tree::ptree const ¶ms)\n+void AwbPrior::read(boost::property_tree::ptree const ¶ms)\n {\n \tlux = params.get<double>(\"lux\");\n-\tprior.Read(params.get_child(\"prior\"));\n+\tprior.read(params.get_child(\"prior\"));\n }\n \n-static void read_ct_curve(Pwl &ct_r, Pwl &ct_b,\n-\t\t\t boost::property_tree::ptree const ¶ms)\n+static void readCtCurve(Pwl &ctR, Pwl &ctB,\n+\t\t\tboost::property_tree::ptree const ¶ms)\n {\n \tint num = 0;\n \tfor (auto it = params.begin(); it != params.end(); it++) {\n \t\tdouble ct = it->second.get_value<double>();\n-\t\tassert(it == params.begin() || ct != ct_r.Domain().end);\n+\t\tassert(it == params.begin() || ct != ctR.domain().end);\n \t\tif (++it == params.end())\n \t\t\tthrow std::runtime_error(\n \t\t\t\t\"AwbConfig: incomplete CT curve entry\");\n-\t\tct_r.Append(ct, it->second.get_value<double>());\n+\t\tctR.append(ct, it->second.get_value<double>());\n \t\tif (++it == params.end())\n \t\t\tthrow std::runtime_error(\n \t\t\t\t\"AwbConfig: incomplete CT curve entry\");\n-\t\tct_b.Append(ct, it->second.get_value<double>());\n+\t\tctB.append(ct, it->second.get_value<double>());\n \t\tnum++;\n \t}\n \tif (num < 2)\n@@ -58,22 +58,21 @@ static void read_ct_curve(Pwl &ct_r, Pwl &ct_b,\n \t\t\t\"AwbConfig: insufficient points in CT curve\");\n }\n \n-void AwbConfig::Read(boost::property_tree::ptree const ¶ms)\n+void AwbConfig::read(boost::property_tree::ptree const ¶ms)\n {\n \tbayes = params.get<int>(\"bayes\", 1);\n-\tframe_period = params.get<uint16_t>(\"frame_period\", 10);\n-\tstartup_frames = params.get<uint16_t>(\"startup_frames\", 10);\n-\tconvergence_frames = params.get<unsigned int>(\"convergence_frames\", 3);\n+\tframePeriod = params.get<uint16_t>(\"framePeriod\", 10);\n+\tstartupFrames = params.get<uint16_t>(\"startupFrames\", 10);\n+\tconvergenceFrames = params.get<unsigned int>(\"convergence_frames\", 3);\n \tspeed = params.get<double>(\"speed\", 0.05);\n \tif (params.get_child_optional(\"ct_curve\"))\n-\t\tread_ct_curve(ct_r, ct_b, params.get_child(\"ct_curve\"));\n+\t\treadCtCurve(ctR, ctB, params.get_child(\"ct_curve\"));\n \tif (params.get_child_optional(\"priors\")) {\n \t\tfor (auto &p : params.get_child(\"priors\")) {\n \t\t\tAwbPrior prior;\n-\t\t\tprior.Read(p.second);\n+\t\t\tprior.read(p.second);\n \t\t\tif (!priors.empty() && prior.lux <= priors.back().lux)\n-\t\t\t\tthrow std::runtime_error(\n-\t\t\t\t\t\"AwbConfig: Prior must be ordered in increasing lux value\");\n+\t\t\t\tthrow std::runtime_error(\"AwbConfig: Prior must be ordered in increasing lux value\");\n \t\t\tpriors.push_back(prior);\n \t\t}\n \t\tif (priors.empty())\n@@ -82,177 +81,170 @@ void AwbConfig::Read(boost::property_tree::ptree const ¶ms)\n \t}\n \tif (params.get_child_optional(\"modes\")) {\n \t\tfor (auto &p : params.get_child(\"modes\")) {\n-\t\t\tmodes[p.first].Read(p.second);\n-\t\t\tif (default_mode == nullptr)\n-\t\t\t\tdefault_mode = &modes[p.first];\n+\t\t\tmodes[p.first].read(p.second);\n+\t\t\tif (defaultMode == nullptr)\n+\t\t\t\tdefaultMode = &modes[p.first];\n \t\t}\n-\t\tif (default_mode == nullptr)\n-\t\t\tthrow std::runtime_error(\n-\t\t\t\t\"AwbConfig: no AWB modes configured\");\n+\t\tif (defaultMode == nullptr)\n+\t\t\tthrow std::runtime_error(\"AwbConfig: no AWB modes configured\");\n \t}\n-\tmin_pixels = params.get<double>(\"min_pixels\", 16.0);\n-\tmin_G = params.get<uint16_t>(\"min_G\", 32);\n-\tmin_regions = params.get<uint32_t>(\"min_regions\", 10);\n-\tdelta_limit = params.get<double>(\"delta_limit\", 0.2);\n-\tcoarse_step = params.get<double>(\"coarse_step\", 0.2);\n-\ttransverse_pos = params.get<double>(\"transverse_pos\", 0.01);\n-\ttransverse_neg = params.get<double>(\"transverse_neg\", 0.01);\n-\tif (transverse_pos <= 0 || transverse_neg <= 0)\n-\t\tthrow std::runtime_error(\n-\t\t\t\"AwbConfig: transverse_pos/neg must be > 0\");\n-\tsensitivity_r = params.get<double>(\"sensitivity_r\", 1.0);\n-\tsensitivity_b = params.get<double>(\"sensitivity_b\", 1.0);\n+\tminPixels = params.get<double>(\"min_pixels\", 16.0);\n+\tminG = params.get<uint16_t>(\"min_G\", 32);\n+\tminRegions = params.get<uint32_t>(\"min_regions\", 10);\n+\tdeltaLimit = params.get<double>(\"delta_limit\", 0.2);\n+\tcoarseStep = params.get<double>(\"coarse_step\", 0.2);\n+\ttransversePos = params.get<double>(\"transverse_pos\", 0.01);\n+\ttransverseNeg = params.get<double>(\"transverse_neg\", 0.01);\n+\tif (transversePos <= 0 || transverseNeg <= 0)\n+\t\tthrow std::runtime_error(\"AwbConfig: transverse_pos/neg must be > 0\");\n+\tsensitivityR = params.get<double>(\"sensitivity_r\", 1.0);\n+\tsensitivityB = params.get<double>(\"sensitivity_b\", 1.0);\n \tif (bayes) {\n-\t\tif (ct_r.Empty() || ct_b.Empty() || priors.empty() ||\n-\t\t default_mode == nullptr) {\n+\t\tif (ctR.empty() || ctB.empty() || priors.empty() ||\n+\t\t defaultMode == nullptr) {\n \t\t\tLOG(RPiAwb, Warning)\n \t\t\t\t<< \"Bayesian AWB mis-configured - switch to Grey method\";\n \t\t\tbayes = false;\n \t\t}\n \t}\n-\tfast = params.get<int>(\n-\t\t\"fast\", bayes); // default to fast for Bayesian, otherwise slow\n-\twhitepoint_r = params.get<double>(\"whitepoint_r\", 0.0);\n-\twhitepoint_b = params.get<double>(\"whitepoint_b\", 0.0);\n+\tfast = params.get<int>(\"fast\", bayes); // default to fast for Bayesian, otherwise slow\n+\twhitepointR = params.get<double>(\"whitepoint_r\", 0.0);\n+\twhitepointB = params.get<double>(\"whitepoint_b\", 0.0);\n \tif (bayes == false)\n-\t\tsensitivity_r = sensitivity_b =\n-\t\t\t1.0; // nor do sensitivities make any sense\n+\t\tsensitivityR = sensitivityB = 1.0; // nor do sensitivities make any sense\n }\n \n Awb::Awb(Controller *controller)\n \t: AwbAlgorithm(controller)\n {\n-\tasync_abort_ = async_start_ = async_started_ = async_finished_ = false;\n+\tasyncAbort_ = asyncStart_ = asyncStarted_ = asyncFinished_ = 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+\tmanualR_ = manualB_ = 0.0;\n+\tfirstSwitchMode_ = true;\n+\tasyncThread_ = std::thread(std::bind(&Awb::asyncFunc, this));\n }\n \n Awb::~Awb()\n {\n \t{\n \t\tstd::lock_guard<std::mutex> lock(mutex_);\n-\t\tasync_abort_ = true;\n+\t\tasyncAbort_ = true;\n \t}\n-\tasync_signal_.notify_one();\n-\tasync_thread_.join();\n+\tasyncSignal_.notify_one();\n+\tasyncThread_.join();\n }\n \n-char const *Awb::Name() const\n+char const *Awb::name() const\n {\n \treturn NAME;\n }\n \n-void Awb::Read(boost::property_tree::ptree const ¶ms)\n+void Awb::read(boost::property_tree::ptree const ¶ms)\n {\n-\tconfig_.Read(params);\n+\tconfig_.read(params);\n }\n \n-void Awb::Initialise()\n+void Awb::initialise()\n {\n-\tframe_count_ = frame_phase_ = 0;\n+\tframeCount_ = framePhase_ = 0;\n \t// Put something sane into the status that we are filtering towards,\n \t// just in case the first few frames don't have anything meaningful in\n \t// them.\n-\tif (!config_.ct_r.Empty() && !config_.ct_b.Empty()) {\n-\t\tsync_results_.temperature_K = config_.ct_r.Domain().Clip(4000);\n-\t\tsync_results_.gain_r =\n-\t\t\t1.0 / config_.ct_r.Eval(sync_results_.temperature_K);\n-\t\tsync_results_.gain_g = 1.0;\n-\t\tsync_results_.gain_b =\n-\t\t\t1.0 / config_.ct_b.Eval(sync_results_.temperature_K);\n+\tif (!config_.ctR.empty() && !config_.ctB.empty()) {\n+\t\tsyncResults_.temperatureK = config_.ctR.domain().clip(4000);\n+\t\tsyncResults_.gainR = 1.0 / config_.ctR.eval(syncResults_.temperatureK);\n+\t\tsyncResults_.gainG = 1.0;\n+\t\tsyncResults_.gainB = 1.0 / config_.ctB.eval(syncResults_.temperatureK);\n \t} else {\n \t\t// random values just to stop the world blowing up\n-\t\tsync_results_.temperature_K = 4500;\n-\t\tsync_results_.gain_r = sync_results_.gain_g =\n-\t\t\tsync_results_.gain_b = 1.0;\n+\t\tsyncResults_.temperatureK = 4500;\n+\t\tsyncResults_.gainR = syncResults_.gainG = syncResults_.gainB = 1.0;\n \t}\n-\tprev_sync_results_ = sync_results_;\n-\tasync_results_ = sync_results_;\n+\tprevSyncResults_ = syncResults_;\n+\tasyncResults_ = syncResults_;\n }\n \n-bool Awb::IsPaused() const\n+bool Awb::isPaused() const\n {\n \treturn false;\n }\n \n-void Awb::Pause()\n+void Awb::pause()\n {\n \t// \"Pause\" by fixing everything to the most recent values.\n-\tmanual_r_ = sync_results_.gain_r = prev_sync_results_.gain_r;\n-\tmanual_b_ = sync_results_.gain_b = prev_sync_results_.gain_b;\n-\tsync_results_.gain_g = prev_sync_results_.gain_g;\n-\tsync_results_.temperature_K = prev_sync_results_.temperature_K;\n+\tmanualR_ = syncResults_.gainR = prevSyncResults_.gainR;\n+\tmanualB_ = syncResults_.gainB = prevSyncResults_.gainB;\n+\tsyncResults_.gainG = prevSyncResults_.gainG;\n+\tsyncResults_.temperatureK = prevSyncResults_.temperatureK;\n }\n \n-void Awb::Resume()\n+void Awb::resume()\n {\n-\tmanual_r_ = 0.0;\n-\tmanual_b_ = 0.0;\n+\tmanualR_ = 0.0;\n+\tmanualB_ = 0.0;\n }\n \n-unsigned int Awb::GetConvergenceFrames() const\n+unsigned int Awb::getConvergenceFrames() const\n {\n \t// If not in auto mode, there is no convergence\n \t// to happen, so no need to drop any frames - return zero.\n \tif (!isAutoEnabled())\n \t\treturn 0;\n \telse\n-\t\treturn config_.convergence_frames;\n+\t\treturn config_.convergenceFrames;\n }\n \n-void Awb::SetMode(std::string const &mode_name)\n+void Awb::setMode(std::string const &modeName)\n {\n-\tmode_name_ = mode_name;\n+\tmodeName_ = modeName;\n }\n \n-void Awb::SetManualGains(double manual_r, double manual_b)\n+void Awb::setManualGains(double manualR, double manualB)\n {\n \t// If any of these are 0.0, we swich back to auto.\n-\tmanual_r_ = manual_r;\n-\tmanual_b_ = manual_b;\n+\tmanualR_ = manualR;\n+\tmanualB_ = manualB;\n \t// If not in auto mode, set these values into the sync_results which\n \t// means that Prepare() will adopt them immediately.\n \tif (!isAutoEnabled()) {\n-\t\tsync_results_.gain_r = prev_sync_results_.gain_r = manual_r_;\n-\t\tsync_results_.gain_g = prev_sync_results_.gain_g = 1.0;\n-\t\tsync_results_.gain_b = prev_sync_results_.gain_b = manual_b_;\n+\t\tsyncResults_.gainR = prevSyncResults_.gainR = manualR_;\n+\t\tsyncResults_.gainG = prevSyncResults_.gainG = 1.0;\n+\t\tsyncResults_.gainB = prevSyncResults_.gainB = manualB_;\n \t}\n }\n \n-void Awb::SwitchMode([[maybe_unused]] CameraMode const &camera_mode,\n+void Awb::switchMode([[maybe_unused]] CameraMode const &cameraMode,\n \t\t Metadata *metadata)\n {\n \t// On the first mode switch we'll have no meaningful colour\n \t// temperature, so try to dead reckon one if in manual mode.\n-\tif (!isAutoEnabled() && first_switch_mode_ && config_.bayes) {\n-\t\tPwl ct_r_inverse = config_.ct_r.Inverse();\n-\t\tPwl ct_b_inverse = config_.ct_b.Inverse();\n-\t\tdouble ct_r = ct_r_inverse.Eval(ct_r_inverse.Domain().Clip(1 / manual_r_));\n-\t\tdouble ct_b = ct_b_inverse.Eval(ct_b_inverse.Domain().Clip(1 / manual_b_));\n-\t\tprev_sync_results_.temperature_K = (ct_r + ct_b) / 2;\n-\t\tsync_results_.temperature_K = prev_sync_results_.temperature_K;\n+\tif (!isAutoEnabled() && firstSwitchMode_ && config_.bayes) {\n+\t\tPwl ctRInverse = config_.ctR.inverse();\n+\t\tPwl ctBInverse = config_.ctB.inverse();\n+\t\tdouble ctR = ctRInverse.eval(ctRInverse.domain().clip(1 / manualR_));\n+\t\tdouble ctB = ctBInverse.eval(ctBInverse.domain().clip(1 / manualB_));\n+\t\tprevSyncResults_.temperatureK = (ctR + ctB) / 2;\n+\t\tsyncResults_.temperatureK = prevSyncResults_.temperatureK;\n \t}\n \t// Let other algorithms know the current white balance values.\n-\tmetadata->Set(\"awb.status\", prev_sync_results_);\n-\tfirst_switch_mode_ = false;\n+\tmetadata->set(\"awb.status\", prevSyncResults_);\n+\tfirstSwitchMode_ = false;\n }\n \n bool Awb::isAutoEnabled() const\n {\n-\treturn manual_r_ == 0.0 || manual_b_ == 0.0;\n+\treturn manualR_ == 0.0 || manualB_ == 0.0;\n }\n \n void Awb::fetchAsyncResults()\n {\n \tLOG(RPiAwb, Debug) << \"Fetch AWB results\";\n-\tasync_finished_ = false;\n-\tasync_started_ = false;\n+\tasyncFinished_ = false;\n+\tasyncStarted_ = false;\n \t// It's possible manual gains could be set even while the async\n \t// thread was running, so only copy the results if still in auto mode.\n \tif (isAutoEnabled())\n-\t\tsync_results_ = async_results_;\n+\t\tsyncResults_ = asyncResults_;\n }\n \n void Awb::restartAsync(StatisticsPtr &stats, double lux)\n@@ -261,75 +253,74 @@ void Awb::restartAsync(StatisticsPtr &stats, double lux)\n \t// this makes a new reference which belongs to the asynchronous thread\n \tstatistics_ = stats;\n \t// store the mode as it could technically change\n-\tauto m = config_.modes.find(mode_name_);\n+\tauto m = config_.modes.find(modeName_);\n \tmode_ = m != config_.modes.end()\n \t\t\t? &m->second\n-\t\t\t: (mode_ == nullptr ? config_.default_mode : mode_);\n+\t\t\t: (mode_ == nullptr ? config_.defaultMode : mode_);\n \tlux_ = lux;\n-\tframe_phase_ = 0;\n-\tasync_started_ = true;\n-\tsize_t len = mode_name_.copy(async_results_.mode,\n-\t\t\t\t sizeof(async_results_.mode) - 1);\n-\tasync_results_.mode[len] = '\\0';\n+\tframePhase_ = 0;\n+\tasyncStarted_ = true;\n+\tsize_t len = modeName_.copy(asyncResults_.mode,\n+\t\t\t\t sizeof(asyncResults_.mode) - 1);\n+\tasyncResults_.mode[len] = '\\0';\n \t{\n \t\tstd::lock_guard<std::mutex> lock(mutex_);\n-\t\tasync_start_ = true;\n+\t\tasyncStart_ = true;\n \t}\n-\tasync_signal_.notify_one();\n+\tasyncSignal_.notify_one();\n }\n \n-void Awb::Prepare(Metadata *image_metadata)\n+void Awb::prepare(Metadata *imageMetadata)\n {\n-\tif (frame_count_ < (int)config_.startup_frames)\n-\t\tframe_count_++;\n-\tdouble speed = frame_count_ < (int)config_.startup_frames\n+\tif (frameCount_ < (int)config_.startupFrames)\n+\t\tframeCount_++;\n+\tdouble speed = frameCount_ < (int)config_.startupFrames\n \t\t\t ? 1.0\n \t\t\t : config_.speed;\n \tLOG(RPiAwb, Debug)\n-\t\t<< \"frame_count \" << frame_count_ << \" speed \" << speed;\n+\t\t<< \"frame_count \" << frameCount_ << \" speed \" << speed;\n \t{\n \t\tstd::unique_lock<std::mutex> lock(mutex_);\n-\t\tif (async_started_ && async_finished_)\n+\t\tif (asyncStarted_ && asyncFinished_)\n \t\t\tfetchAsyncResults();\n \t}\n \t// Finally apply IIR filter to results and put into metadata.\n-\tmemcpy(prev_sync_results_.mode, sync_results_.mode,\n-\t sizeof(prev_sync_results_.mode));\n-\tprev_sync_results_.temperature_K =\n-\t\tspeed * sync_results_.temperature_K +\n-\t\t(1.0 - speed) * prev_sync_results_.temperature_K;\n-\tprev_sync_results_.gain_r = speed * sync_results_.gain_r +\n-\t\t\t\t (1.0 - speed) * prev_sync_results_.gain_r;\n-\tprev_sync_results_.gain_g = speed * sync_results_.gain_g +\n-\t\t\t\t (1.0 - speed) * prev_sync_results_.gain_g;\n-\tprev_sync_results_.gain_b = speed * sync_results_.gain_b +\n-\t\t\t\t (1.0 - speed) * prev_sync_results_.gain_b;\n-\timage_metadata->Set(\"awb.status\", prev_sync_results_);\n+\tmemcpy(prevSyncResults_.mode, syncResults_.mode,\n+\t sizeof(prevSyncResults_.mode));\n+\tprevSyncResults_.temperatureK = speed * syncResults_.temperatureK +\n+\t\t\t\t\t(1.0 - speed) * prevSyncResults_.temperatureK;\n+\tprevSyncResults_.gainR = speed * syncResults_.gainR +\n+\t\t\t\t (1.0 - speed) * prevSyncResults_.gainR;\n+\tprevSyncResults_.gainG = speed * syncResults_.gainG +\n+\t\t\t\t (1.0 - speed) * prevSyncResults_.gainG;\n+\tprevSyncResults_.gainB = speed * syncResults_.gainB +\n+\t\t\t\t (1.0 - speed) * prevSyncResults_.gainB;\n+\timageMetadata->set(\"awb.status\", prevSyncResults_);\n \tLOG(RPiAwb, Debug)\n-\t\t<< \"Using AWB gains r \" << prev_sync_results_.gain_r << \" g \"\n-\t\t<< prev_sync_results_.gain_g << \" b \"\n-\t\t<< prev_sync_results_.gain_b;\n+\t\t<< \"Using AWB gains r \" << prevSyncResults_.gainR << \" g \"\n+\t\t<< prevSyncResults_.gainG << \" b \"\n+\t\t<< prevSyncResults_.gainB;\n }\n \n-void Awb::Process(StatisticsPtr &stats, Metadata *image_metadata)\n+void Awb::process(StatisticsPtr &stats, Metadata *imageMetadata)\n {\n \t// Count frames since we last poked the async thread.\n-\tif (frame_phase_ < (int)config_.frame_period)\n-\t\tframe_phase_++;\n-\tLOG(RPiAwb, Debug) << \"frame_phase \" << frame_phase_;\n+\tif (framePhase_ < (int)config_.framePeriod)\n+\t\tframePhase_++;\n+\tLOG(RPiAwb, Debug) << \"frame_phase \" << framePhase_;\n \t// We do not restart the async thread if we're not in auto mode.\n \tif (isAutoEnabled() &&\n-\t (frame_phase_ >= (int)config_.frame_period ||\n-\t frame_count_ < (int)config_.startup_frames)) {\n+\t (framePhase_ >= (int)config_.framePeriod ||\n+\t frameCount_ < (int)config_.startupFrames)) {\n \t\t// Update any settings and any image metadata that we need.\n-\t\tstruct LuxStatus lux_status = {};\n-\t\tlux_status.lux = 400; // in case no metadata\n-\t\tif (image_metadata->Get(\"lux.status\", lux_status) != 0)\n+\t\tstruct LuxStatus luxStatus = {};\n+\t\tluxStatus.lux = 400; // in case no metadata\n+\t\tif (imageMetadata->get(\"lux.status\", luxStatus) != 0)\n \t\t\tLOG(RPiAwb, Debug) << \"No lux metadata found\";\n-\t\tLOG(RPiAwb, Debug) << \"Awb lux value is \" << lux_status.lux;\n+\t\tLOG(RPiAwb, Debug) << \"Awb lux value is \" << luxStatus.lux;\n \n-\t\tif (async_started_ == false)\n-\t\t\trestartAsync(stats, lux_status.lux);\n+\t\tif (asyncStarted_ == false)\n+\t\t\trestartAsync(stats, luxStatus.lux);\n \t}\n }\n \n@@ -338,32 +329,32 @@ void Awb::asyncFunc()\n \twhile (true) {\n \t\t{\n \t\t\tstd::unique_lock<std::mutex> lock(mutex_);\n-\t\t\tasync_signal_.wait(lock, [&] {\n-\t\t\t\treturn async_start_ || async_abort_;\n+\t\t\tasyncSignal_.wait(lock, [&] {\n+\t\t\t\treturn asyncStart_ || asyncAbort_;\n \t\t\t});\n-\t\t\tasync_start_ = false;\n-\t\t\tif (async_abort_)\n+\t\t\tasyncStart_ = false;\n+\t\t\tif (asyncAbort_)\n \t\t\t\tbreak;\n \t\t}\n \t\tdoAwb();\n \t\t{\n \t\t\tstd::lock_guard<std::mutex> lock(mutex_);\n-\t\t\tasync_finished_ = true;\n+\t\t\tasyncFinished_ = true;\n \t\t}\n-\t\tsync_signal_.notify_one();\n+\t\tsyncSignal_.notify_one();\n \t}\n }\n \n-static void generate_stats(std::vector<Awb::RGB> &zones,\n-\t\t\t bcm2835_isp_stats_region *stats, double min_pixels,\n-\t\t\t double min_G)\n+static void generateStats(std::vector<Awb::RGB> &zones,\n+\t\t\t bcm2835_isp_stats_region *stats, double minPixels,\n+\t\t\t double minG)\n {\n \tfor (int i = 0; i < AWB_STATS_SIZE_X * AWB_STATS_SIZE_Y; i++) {\n \t\tAwb::RGB zone;\n \t\tdouble counted = stats[i].counted;\n-\t\tif (counted >= min_pixels) {\n+\t\tif (counted >= minPixels) {\n \t\t\tzone.G = stats[i].g_sum / counted;\n-\t\t\tif (zone.G >= min_G) {\n+\t\t\tif (zone.G >= minG) {\n \t\t\t\tzone.R = stats[i].r_sum / counted;\n \t\t\t\tzone.B = stats[i].b_sum / counted;\n \t\t\t\tzones.push_back(zone);\n@@ -377,32 +368,33 @@ void Awb::prepareStats()\n \tzones_.clear();\n \t// LSC has already been applied to the stats in this pipeline, so stop\n \t// any LSC compensation. We also ignore config_.fast in this version.\n-\tgenerate_stats(zones_, statistics_->awb_stats, config_.min_pixels,\n-\t\t config_.min_G);\n+\tgenerateStats(zones_, statistics_->awb_stats, config_.minPixels,\n+\t\t config_.minG);\n \t// we're done with these; we may as well relinquish our hold on the\n \t// pointer.\n \tstatistics_.reset();\n \t// apply sensitivities, so values appear to come from our \"canonical\"\n \t// sensor.\n-\tfor (auto &zone : zones_)\n-\t\tzone.R *= config_.sensitivity_r,\n-\t\t\tzone.B *= config_.sensitivity_b;\n+\tfor (auto &zone : zones_) {\n+\t\tzone.R *= config_.sensitivityR;\n+\t\tzone.B *= config_.sensitivityB;\n+\t}\n }\n \n-double Awb::computeDelta2Sum(double gain_r, double gain_b)\n+double Awb::computeDelta2Sum(double gainR, double gainB)\n {\n \t// Compute the sum of the squared colour error (non-greyness) as it\n \t// appears in the log likelihood equation.\n-\tdouble delta2_sum = 0;\n+\tdouble delta2Sum = 0;\n \tfor (auto &z : zones_) {\n-\t\tdouble delta_r = gain_r * z.R - 1 - config_.whitepoint_r;\n-\t\tdouble delta_b = gain_b * z.B - 1 - config_.whitepoint_b;\n-\t\tdouble delta2 = delta_r * delta_r + delta_b * delta_b;\n+\t\tdouble deltaR = gainR * z.R - 1 - config_.whitepointR;\n+\t\tdouble deltaB = gainB * z.B - 1 - config_.whitepointB;\n+\t\tdouble delta2 = deltaR * deltaR + deltaB * deltaB;\n \t\t//LOG(RPiAwb, Debug) << \"delta_r \" << delta_r << \" delta_b \" << delta_b << \" delta2 \" << delta2;\n-\t\tdelta2 = std::min(delta2, config_.delta_limit);\n-\t\tdelta2_sum += delta2;\n+\t\tdelta2 = std::min(delta2, config_.deltaLimit);\n+\t\tdelta2Sum += delta2;\n \t}\n-\treturn delta2_sum;\n+\treturn delta2Sum;\n }\n \n Pwl Awb::interpolatePrior()\n@@ -420,7 +412,7 @@ Pwl Awb::interpolatePrior()\n \t\t\tidx++;\n \t\tdouble lux0 = config_.priors[idx].lux,\n \t\t lux1 = config_.priors[idx + 1].lux;\n-\t\treturn Pwl::Combine(config_.priors[idx].prior,\n+\t\treturn Pwl::combine(config_.priors[idx].prior,\n \t\t\t\t config_.priors[idx + 1].prior,\n \t\t\t\t [&](double /*x*/, double y0, double y1) {\n \t\t\t\t\t return y0 + (y1 - y0) *\n@@ -429,62 +421,60 @@ Pwl Awb::interpolatePrior()\n \t}\n }\n \n-static double interpolate_quadatric(Pwl::Point const &A, Pwl::Point const &B,\n-\t\t\t\t Pwl::Point const &C)\n+static double interpolateQuadatric(Pwl::Point const &a, Pwl::Point const &b,\n+\t\t\t\t Pwl::Point const &c)\n {\n \t// Given 3 points on a curve, find the extremum of the function in that\n \t// interval by fitting a quadratic.\n \tconst double eps = 1e-3;\n-\tPwl::Point CA = C - A, BA = B - A;\n-\tdouble denominator = 2 * (BA.y * CA.x - CA.y * BA.x);\n+\tPwl::Point ca = c - a, ba = b - a;\n+\tdouble denominator = 2 * (ba.y * ca.x - ca.y * ba.x);\n \tif (abs(denominator) > eps) {\n-\t\tdouble numerator = BA.y * CA.x * CA.x - CA.y * BA.x * BA.x;\n-\t\tdouble result = numerator / denominator + A.x;\n-\t\treturn std::max(A.x, std::min(C.x, result));\n+\t\tdouble numerator = ba.y * ca.x * ca.x - ca.y * ba.x * ba.x;\n+\t\tdouble result = numerator / denominator + a.x;\n+\t\treturn std::max(a.x, std::min(c.x, result));\n \t}\n \t// has degenerated to straight line segment\n-\treturn A.y < C.y - eps ? A.x : (C.y < A.y - eps ? C.x : B.x);\n+\treturn a.y < c.y - eps ? a.x : (c.y < a.y - eps ? c.x : b.x);\n }\n \n double Awb::coarseSearch(Pwl const &prior)\n {\n \tpoints_.clear(); // assume doesn't deallocate memory\n-\tsize_t best_point = 0;\n-\tdouble t = mode_->ct_lo;\n-\tint span_r = 0, span_b = 0;\n+\tsize_t bestPoint = 0;\n+\tdouble t = mode_->ctLo;\n+\tint spanR = 0, spanB = 0;\n \t// Step down the CT curve evaluating log likelihood.\n \twhile (true) {\n-\t\tdouble r = config_.ct_r.Eval(t, &span_r);\n-\t\tdouble b = config_.ct_b.Eval(t, &span_b);\n-\t\tdouble gain_r = 1 / r, gain_b = 1 / b;\n-\t\tdouble delta2_sum = computeDelta2Sum(gain_r, gain_b);\n-\t\tdouble prior_log_likelihood =\n-\t\t\tprior.Eval(prior.Domain().Clip(t));\n-\t\tdouble final_log_likelihood = delta2_sum - prior_log_likelihood;\n+\t\tdouble r = config_.ctR.eval(t, &spanR);\n+\t\tdouble b = config_.ctB.eval(t, &spanB);\n+\t\tdouble gainR = 1 / r, gainB = 1 / b;\n+\t\tdouble delta2Sum = computeDelta2Sum(gainR, gainB);\n+\t\tdouble priorLogLikelihood = prior.eval(prior.domain().clip(t));\n+\t\tdouble finalLogLikelihood = delta2Sum - priorLogLikelihood;\n \t\tLOG(RPiAwb, Debug)\n-\t\t\t<< \"t: \" << t << \" gain_r \" << gain_r << \" gain_b \"\n-\t\t\t<< gain_b << \" delta2_sum \" << delta2_sum\n-\t\t\t<< \" prior \" << prior_log_likelihood << \" final \"\n-\t\t\t<< final_log_likelihood;\n-\t\tpoints_.push_back(Pwl::Point(t, final_log_likelihood));\n-\t\tif (points_.back().y < points_[best_point].y)\n-\t\t\tbest_point = points_.size() - 1;\n-\t\tif (t == mode_->ct_hi)\n+\t\t\t<< \"t: \" << t << \" gain R \" << gainR << \" gain B \"\n+\t\t\t<< gainB << \" delta2_sum \" << delta2Sum\n+\t\t\t<< \" prior \" << priorLogLikelihood << \" final \"\n+\t\t\t<< finalLogLikelihood;\n+\t\tpoints_.push_back(Pwl::Point(t, finalLogLikelihood));\n+\t\tif (points_.back().y < points_[bestPoint].y)\n+\t\t\tbestPoint = points_.size() - 1;\n+\t\tif (t == mode_->ctHi)\n \t\t\tbreak;\n \t\t// for even steps along the r/b curve scale them by the current t\n-\t\tt = std::min(t + t / 10 * config_.coarse_step,\n-\t\t\t mode_->ct_hi);\n+\t\tt = std::min(t + t / 10 * config_.coarseStep, mode_->ctHi);\n \t}\n-\tt = points_[best_point].x;\n+\tt = points_[bestPoint].x;\n \tLOG(RPiAwb, Debug) << \"Coarse search found CT \" << t;\n \t// We have the best point of the search, but refine it with a quadratic\n \t// interpolation around its neighbours.\n \tif (points_.size() > 2) {\n-\t\tunsigned long bp = std::min(best_point, points_.size() - 2);\n-\t\tbest_point = std::max(1UL, bp);\n-\t\tt = interpolate_quadatric(points_[best_point - 1],\n-\t\t\t\t\t points_[best_point],\n-\t\t\t\t\t points_[best_point + 1]);\n+\t\tunsigned long bp = std::min(bestPoint, points_.size() - 2);\n+\t\tbestPoint = std::max(1UL, bp);\n+\t\tt = interpolateQuadatric(points_[bestPoint - 1],\n+\t\t\t\t\t points_[bestPoint],\n+\t\t\t\t\t points_[bestPoint + 1]);\n \t\tLOG(RPiAwb, Debug)\n \t\t\t<< \"After quadratic refinement, coarse search has CT \"\n \t\t\t<< t;\n@@ -494,80 +484,76 @@ double Awb::coarseSearch(Pwl const &prior)\n \n void Awb::fineSearch(double &t, double &r, double &b, Pwl const &prior)\n {\n-\tint span_r = -1, span_b = -1;\n-\tconfig_.ct_r.Eval(t, &span_r);\n-\tconfig_.ct_b.Eval(t, &span_b);\n-\tdouble step = t / 10 * config_.coarse_step * 0.1;\n+\tint spanR = -1, spanB = -1;\n+\tconfig_.ctR.eval(t, &spanR);\n+\tconfig_.ctB.eval(t, &spanB);\n+\tdouble step = t / 10 * config_.coarseStep * 0.1;\n \tint nsteps = 5;\n-\tdouble r_diff = config_.ct_r.Eval(t + nsteps * step, &span_r) -\n-\t\t\tconfig_.ct_r.Eval(t - nsteps * step, &span_r);\n-\tdouble b_diff = config_.ct_b.Eval(t + nsteps * step, &span_b) -\n-\t\t\tconfig_.ct_b.Eval(t - nsteps * step, &span_b);\n-\tPwl::Point transverse(b_diff, -r_diff);\n-\tif (transverse.Len2() < 1e-6)\n+\tdouble rDiff = config_.ctR.eval(t + nsteps * step, &spanR) -\n+\t\t config_.ctR.eval(t - nsteps * step, &spanR);\n+\tdouble bDiff = config_.ctB.eval(t + nsteps * step, &spanB) -\n+\t\t config_.ctB.eval(t - nsteps * step, &spanB);\n+\tPwl::Point transverse(bDiff, -rDiff);\n+\tif (transverse.len2() < 1e-6)\n \t\treturn;\n \t// unit vector orthogonal to the b vs. r function (pointing outwards\n \t// with r and b increasing)\n-\ttransverse = transverse / transverse.Len();\n-\tdouble best_log_likelihood = 0, best_t = 0, best_r = 0, best_b = 0;\n-\tdouble transverse_range =\n-\t\tconfig_.transverse_neg + config_.transverse_pos;\n-\tconst int MAX_NUM_DELTAS = 12;\n+\ttransverse = transverse / transverse.len();\n+\tdouble bestLogLikelihood = 0, bestT = 0, bestR = 0, bestB = 0;\n+\tdouble transverseRange = config_.transverseNeg + config_.transversePos;\n+\tconst int maxNumDeltas = 12;\n \t// a transverse step approximately every 0.01 r/b units\n-\tint num_deltas = floor(transverse_range * 100 + 0.5) + 1;\n-\tnum_deltas = num_deltas < 3 ? 3 :\n-\t\t (num_deltas > MAX_NUM_DELTAS ? MAX_NUM_DELTAS : num_deltas);\n+\tint numDeltas = floor(transverseRange * 100 + 0.5) + 1;\n+\tnumDeltas = numDeltas < 3 ? 3 : (numDeltas > maxNumDeltas ? maxNumDeltas : numDeltas);\n \t// Step down CT curve. March a bit further if the transverse range is\n \t// large.\n-\tnsteps += num_deltas;\n+\tnsteps += numDeltas;\n \tfor (int i = -nsteps; i <= nsteps; i++) {\n-\t\tdouble t_test = t + i * step;\n-\t\tdouble prior_log_likelihood =\n-\t\t\tprior.Eval(prior.Domain().Clip(t_test));\n-\t\tdouble r_curve = config_.ct_r.Eval(t_test, &span_r);\n-\t\tdouble b_curve = config_.ct_b.Eval(t_test, &span_b);\n+\t\tdouble tTest = t + i * step;\n+\t\tdouble priorLogLikelihood =\n+\t\t\tprior.eval(prior.domain().clip(tTest));\n+\t\tdouble rCurve = config_.ctR.eval(tTest, &spanR);\n+\t\tdouble bCurve = config_.ctB.eval(tTest, &spanB);\n \t\t// x will be distance off the curve, y the log likelihood there\n-\t\tPwl::Point points[MAX_NUM_DELTAS];\n-\t\tint best_point = 0;\n+\t\tPwl::Point points[maxNumDeltas];\n+\t\tint bestPoint = 0;\n \t\t// Take some measurements transversely *off* the CT curve.\n-\t\tfor (int j = 0; j < num_deltas; j++) {\n-\t\t\tpoints[j].x = -config_.transverse_neg +\n-\t\t\t\t (transverse_range * j) / (num_deltas - 1);\n-\t\t\tPwl::Point rb_test = Pwl::Point(r_curve, b_curve) +\n-\t\t\t\t\t transverse * points[j].x;\n-\t\t\tdouble r_test = rb_test.x, b_test = rb_test.y;\n-\t\t\tdouble gain_r = 1 / r_test, gain_b = 1 / b_test;\n-\t\t\tdouble delta2_sum = computeDelta2Sum(gain_r, gain_b);\n-\t\t\tpoints[j].y = delta2_sum - prior_log_likelihood;\n+\t\tfor (int j = 0; j < numDeltas; j++) {\n+\t\t\tpoints[j].x = -config_.transverseNeg +\n+\t\t\t\t (transverseRange * j) / (numDeltas - 1);\n+\t\t\tPwl::Point rbTest = Pwl::Point(rCurve, bCurve) +\n+\t\t\t\t\t transverse * points[j].x;\n+\t\t\tdouble rTest = rbTest.x, bTest = rbTest.y;\n+\t\t\tdouble gainR = 1 / rTest, gainB = 1 / bTest;\n+\t\t\tdouble delta2Sum = computeDelta2Sum(gainR, gainB);\n+\t\t\tpoints[j].y = delta2Sum - priorLogLikelihood;\n \t\t\tLOG(RPiAwb, Debug)\n-\t\t\t\t<< \"At t \" << t_test << \" r \" << r_test << \" b \"\n-\t\t\t\t<< b_test << \": \" << points[j].y;\n-\t\t\tif (points[j].y < points[best_point].y)\n-\t\t\t\tbest_point = j;\n+\t\t\t\t<< \"At t \" << tTest << \" r \" << rTest << \" b \"\n+\t\t\t\t<< bTest << \": \" << points[j].y;\n+\t\t\tif (points[j].y < points[bestPoint].y)\n+\t\t\t\tbestPoint = j;\n \t\t}\n \t\t// We have NUM_DELTAS points transversely across the CT curve,\n \t\t// now let's do a quadratic interpolation for the best result.\n-\t\tbest_point = std::max(1, std::min(best_point, num_deltas - 2));\n-\t\tPwl::Point rb_test =\n-\t\t\tPwl::Point(r_curve, b_curve) +\n-\t\t\ttransverse *\n-\t\t\t\tinterpolate_quadatric(points[best_point - 1],\n-\t\t\t\t\t\t points[best_point],\n-\t\t\t\t\t\t points[best_point + 1]);\n-\t\tdouble r_test = rb_test.x, b_test = rb_test.y;\n-\t\tdouble gain_r = 1 / r_test, gain_b = 1 / b_test;\n-\t\tdouble delta2_sum = computeDelta2Sum(gain_r, gain_b);\n-\t\tdouble final_log_likelihood = delta2_sum - prior_log_likelihood;\n+\t\tbestPoint = std::max(1, std::min(bestPoint, numDeltas - 2));\n+\t\tPwl::Point rbTest = Pwl::Point(rCurve, bCurve) +\n+\t\t\t\t\ttransverse * interpolateQuadatric(points[bestPoint - 1],\n+\t\t\t\t\t\t\t\t\tpoints[bestPoint],\n+\t\t\t\t\t\t\t\t\tpoints[bestPoint + 1]);\n+\t\tdouble rTest = rbTest.x, bTest = rbTest.y;\n+\t\tdouble gainR = 1 / rTest, gainB = 1 / bTest;\n+\t\tdouble delta2Sum = computeDelta2Sum(gainR, gainB);\n+\t\tdouble finalLogLikelihood = delta2Sum - priorLogLikelihood;\n \t\tLOG(RPiAwb, Debug)\n \t\t\t<< \"Finally \"\n-\t\t\t<< t_test << \" r \" << r_test << \" b \" << b_test << \": \"\n-\t\t\t<< final_log_likelihood\n-\t\t\t<< (final_log_likelihood < best_log_likelihood ? \" BEST\" : \"\");\n-\t\tif (best_t == 0 || final_log_likelihood < best_log_likelihood)\n-\t\t\tbest_log_likelihood = final_log_likelihood,\n-\t\t\tbest_t = t_test, best_r = r_test, best_b = b_test;\n+\t\t\t<< tTest << \" r \" << rTest << \" b \" << bTest << \": \"\n+\t\t\t<< finalLogLikelihood\n+\t\t\t<< (finalLogLikelihood < bestLogLikelihood ? \" BEST\" : \"\");\n+\t\tif (bestT == 0 || finalLogLikelihood < bestLogLikelihood)\n+\t\t\tbestLogLikelihood = finalLogLikelihood,\n+\t\t\tbestT = tTest, bestR = rTest, bestB = bTest;\n \t}\n-\tt = best_t, r = best_r, b = best_b;\n+\tt = bestT, r = bestR, b = bestB;\n \tLOG(RPiAwb, Debug)\n \t\t<< \"Fine search found t \" << t << \" r \" << r << \" b \" << b;\n }\n@@ -582,12 +568,12 @@ void Awb::awbBayes()\n \t// valid... not entirely sure about this.\n \tPwl prior = interpolatePrior();\n \tprior *= zones_.size() / (double)(AWB_STATS_SIZE_X * AWB_STATS_SIZE_Y);\n-\tprior.Map([](double x, double y) {\n+\tprior.map([](double x, double y) {\n \t\tLOG(RPiAwb, Debug) << \"(\" << x << \",\" << y << \")\";\n \t});\n \tdouble t = coarseSearch(prior);\n-\tdouble r = config_.ct_r.Eval(t);\n-\tdouble b = config_.ct_b.Eval(t);\n+\tdouble r = config_.ctR.eval(t);\n+\tdouble b = config_.ctB.eval(t);\n \tLOG(RPiAwb, Debug)\n \t\t<< \"After coarse search: r \" << r << \" b \" << b << \" (gains r \"\n \t\t<< 1 / r << \" b \" << 1 / b << \")\";\n@@ -604,10 +590,10 @@ void Awb::awbBayes()\n \t// Write results out for the main thread to pick up. Remember to adjust\n \t// the gains from the ones that the \"canonical sensor\" would require to\n \t// the ones needed by *this* sensor.\n-\tasync_results_.temperature_K = t;\n-\tasync_results_.gain_r = 1.0 / r * config_.sensitivity_r;\n-\tasync_results_.gain_g = 1.0;\n-\tasync_results_.gain_b = 1.0 / b * config_.sensitivity_b;\n+\tasyncResults_.temperatureK = t;\n+\tasyncResults_.gainR = 1.0 / r * config_.sensitivityR;\n+\tasyncResults_.gainG = 1.0;\n+\tasyncResults_.gainB = 1.0 / b * config_.sensitivityB;\n }\n \n void Awb::awbGrey()\n@@ -617,51 +603,51 @@ void Awb::awbGrey()\n \t// that we can sort them to exclude the extreme gains. We could\n \t// consider some variations, such as normalising all the zones first, or\n \t// doing an L2 average etc.\n-\tstd::vector<RGB> &derivs_R(zones_);\n-\tstd::vector<RGB> derivs_B(derivs_R);\n-\tstd::sort(derivs_R.begin(), derivs_R.end(),\n+\tstd::vector<RGB> &derivsR(zones_);\n+\tstd::vector<RGB> derivsB(derivsR);\n+\tstd::sort(derivsR.begin(), derivsR.end(),\n \t\t [](RGB const &a, RGB const &b) {\n \t\t\t return a.G * b.R < b.G * a.R;\n \t\t });\n-\tstd::sort(derivs_B.begin(), derivs_B.end(),\n+\tstd::sort(derivsB.begin(), derivsB.end(),\n \t\t [](RGB const &a, RGB const &b) {\n \t\t\t return a.G * b.B < b.G * a.B;\n \t\t });\n \t// Average the middle half of the values.\n-\tint discard = derivs_R.size() / 4;\n-\tRGB sum_R(0, 0, 0), sum_B(0, 0, 0);\n-\tfor (auto ri = derivs_R.begin() + discard,\n-\t\t bi = derivs_B.begin() + discard;\n-\t ri != derivs_R.end() - discard; ri++, bi++)\n-\t\tsum_R += *ri, sum_B += *bi;\n-\tdouble gain_r = sum_R.G / (sum_R.R + 1),\n-\t gain_b = sum_B.G / (sum_B.B + 1);\n-\tasync_results_.temperature_K = 4500; // don't know what it is\n-\tasync_results_.gain_r = gain_r;\n-\tasync_results_.gain_g = 1.0;\n-\tasync_results_.gain_b = gain_b;\n+\tint discard = derivsR.size() / 4;\n+\tRGB sumR(0, 0, 0), sumB(0, 0, 0);\n+\tfor (auto ri = derivsR.begin() + discard,\n+\t\t bi = derivsB.begin() + discard;\n+\t ri != derivsR.end() - discard; ri++, bi++)\n+\t\tsumR += *ri, sumB += *bi;\n+\tdouble gainR = sumR.G / (sumR.R + 1),\n+\t gainB = sumB.G / (sumB.B + 1);\n+\tasyncResults_.temperatureK = 4500; // don't know what it is\n+\tasyncResults_.gainR = gainR;\n+\tasyncResults_.gainG = 1.0;\n+\tasyncResults_.gainB = gainB;\n }\n \n void Awb::doAwb()\n {\n \tprepareStats();\n \tLOG(RPiAwb, Debug) << \"Valid zones: \" << zones_.size();\n-\tif (zones_.size() > config_.min_regions) {\n+\tif (zones_.size() > config_.minRegions) {\n \t\tif (config_.bayes)\n \t\t\tawbBayes();\n \t\telse\n \t\t\tawbGrey();\n \t\tLOG(RPiAwb, Debug)\n \t\t\t<< \"CT found is \"\n-\t\t\t<< async_results_.temperature_K\n-\t\t\t<< \" with gains r \" << async_results_.gain_r\n-\t\t\t<< \" and b \" << async_results_.gain_b;\n+\t\t\t<< asyncResults_.temperatureK\n+\t\t\t<< \" with gains r \" << asyncResults_.gainR\n+\t\t\t<< \" and b \" << asyncResults_.gainB;\n \t}\n }\n \n // Register algorithm with the system.\n-static Algorithm *Create(Controller *controller)\n+static Algorithm *create(Controller *controller)\n {\n \treturn (Algorithm *)new Awb(controller);\n }\n-static RegisterAlgorithm reg(NAME, &Create);\n+static RegisterAlgorithm reg(NAME, &create);\ndiff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp b/src/ipa/raspberrypi/controller/rpi/awb.hpp\nindex ac3dca6f42fc..91251d6be2da 100644\n--- a/src/ipa/raspberrypi/controller/rpi/awb.hpp\n+++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp\n@@ -19,59 +19,59 @@ namespace RPiController {\n // Control algorithm to perform AWB calculations.\n \n struct AwbMode {\n-\tvoid Read(boost::property_tree::ptree const ¶ms);\n-\tdouble ct_lo; // low CT value for search\n-\tdouble ct_hi; // high CT value for search\n+\tvoid read(boost::property_tree::ptree const ¶ms);\n+\tdouble ctLo; // low CT value for search\n+\tdouble ctHi; // high CT value for search\n };\n \n struct AwbPrior {\n-\tvoid Read(boost::property_tree::ptree const ¶ms);\n+\tvoid read(boost::property_tree::ptree const ¶ms);\n \tdouble lux; // lux level\n \tPwl prior; // maps CT to prior log likelihood for this lux level\n };\n \n struct AwbConfig {\n-\tAwbConfig() : default_mode(nullptr) {}\n-\tvoid Read(boost::property_tree::ptree const ¶ms);\n+\tAwbConfig() : defaultMode(nullptr) {}\n+\tvoid read(boost::property_tree::ptree const ¶ms);\n \t// Only repeat the AWB calculation every \"this many\" frames\n-\tuint16_t frame_period;\n+\tuint16_t framePeriod;\n \t// number of initial frames for which speed taken as 1.0 (maximum)\n-\tuint16_t startup_frames;\n-\tunsigned int convergence_frames; // approx number of frames to converge\n+\tuint16_t startupFrames;\n+\tunsigned int convergenceFrames; // approx number of frames to converge\n \tdouble speed; // IIR filter speed applied to algorithm results\n \tbool fast; // \"fast\" mode uses a 16x16 rather than 32x32 grid\n-\tPwl ct_r; // function maps CT to r (= R/G)\n-\tPwl ct_b; // function maps CT to b (= B/G)\n+\tPwl ctR; // function maps CT to r (= R/G)\n+\tPwl ctB; // function maps CT to b (= B/G)\n \t// table of illuminant priors at different lux levels\n \tstd::vector<AwbPrior> priors;\n \t// AWB \"modes\" (determines the search range)\n \tstd::map<std::string, AwbMode> modes;\n-\tAwbMode *default_mode; // mode used if no mode selected\n+\tAwbMode *defaultMode; // mode used if no mode selected\n \t// minimum proportion of pixels counted within AWB region for it to be\n \t// \"useful\"\n-\tdouble min_pixels;\n+\tdouble minPixels;\n \t// minimum G value of those pixels, to be regarded a \"useful\"\n-\tuint16_t min_G;\n+\tuint16_t minG;\n \t// number of AWB regions that must be \"useful\" in order to do the AWB\n \t// calculation\n-\tuint32_t min_regions;\n+\tuint32_t minRegions;\n \t// clamp on colour error term (so as not to penalise non-grey excessively)\n-\tdouble delta_limit;\n+\tdouble deltaLimit;\n \t// step size control in coarse search\n-\tdouble coarse_step;\n+\tdouble coarseStep;\n \t// how far to wander off CT curve towards \"more purple\"\n-\tdouble transverse_pos;\n+\tdouble transversePos;\n \t// how far to wander off CT curve towards \"more green\"\n-\tdouble transverse_neg;\n+\tdouble transverseNeg;\n \t// red sensitivity ratio (set to canonical sensor's R/G divided by this\n \t// sensor's R/G)\n-\tdouble sensitivity_r;\n+\tdouble sensitivityR;\n \t// blue sensitivity ratio (set to canonical sensor's B/G divided by this\n \t// sensor's B/G)\n-\tdouble sensitivity_b;\n+\tdouble sensitivityB;\n \t// The whitepoint (which we normally \"aim\" for) can be moved.\n-\tdouble whitepoint_r;\n-\tdouble whitepoint_b;\n+\tdouble whitepointR;\n+\tdouble whitepointB;\n \tbool bayes; // use Bayesian algorithm\n };\n \n@@ -80,22 +80,22 @@ class Awb : public AwbAlgorithm\n public:\n \tAwb(Controller *controller = NULL);\n \t~Awb();\n-\tchar const *Name() const override;\n-\tvoid Initialise() override;\n-\tvoid Read(boost::property_tree::ptree const ¶ms) override;\n+\tchar const *name() const override;\n+\tvoid initialise() override;\n+\tvoid read(boost::property_tree::ptree const ¶ms) override;\n \t// AWB handles \"pausing\" for itself.\n-\tbool IsPaused() const override;\n-\tvoid Pause() override;\n-\tvoid Resume() override;\n-\tunsigned int GetConvergenceFrames() const override;\n-\tvoid SetMode(std::string const &name) override;\n-\tvoid SetManualGains(double manual_r, double manual_b) override;\n-\tvoid SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override;\n-\tvoid Prepare(Metadata *image_metadata) override;\n-\tvoid Process(StatisticsPtr &stats, Metadata *image_metadata) override;\n+\tbool isPaused() const override;\n+\tvoid pause() override;\n+\tvoid resume() override;\n+\tunsigned int getConvergenceFrames() const override;\n+\tvoid setMode(std::string const &name) override;\n+\tvoid setManualGains(double manualR, double manualB) override;\n+\tvoid switchMode(CameraMode const &cameraMode, Metadata *metadata) override;\n+\tvoid prepare(Metadata *imageMetadata) override;\n+\tvoid process(StatisticsPtr &stats, Metadata *imageMetadata) override;\n \tstruct RGB {\n-\t\tRGB(double _R = 0, double _G = 0, double _B = 0)\n-\t\t\t: R(_R), G(_G), B(_B)\n+\t\tRGB(double r = 0, double g = 0, double b = 0)\n+\t\t\t: R(r), G(g), B(b)\n \t\t{\n \t\t}\n \t\tdouble R, G, B;\n@@ -110,29 +110,29 @@ private:\n \tbool isAutoEnabled() const;\n \t// configuration is read-only, and available to both threads\n \tAwbConfig config_;\n-\tstd::thread async_thread_;\n+\tstd::thread asyncThread_;\n \tvoid asyncFunc(); // asynchronous thread function\n \tstd::mutex mutex_;\n \t// condvar for async thread to wait on\n-\tstd::condition_variable async_signal_;\n+\tstd::condition_variable asyncSignal_;\n \t// condvar for synchronous thread to wait on\n-\tstd::condition_variable sync_signal_;\n+\tstd::condition_variable syncSignal_;\n \t// for sync thread to check if async thread finished (requires mutex)\n-\tbool async_finished_;\n+\tbool asyncFinished_;\n \t// for async thread to check if it's been told to run (requires mutex)\n-\tbool async_start_;\n+\tbool asyncStart_;\n \t// for async thread to check if it's been told to quit (requires mutex)\n-\tbool async_abort_;\n+\tbool asyncAbort_;\n \n \t// The following are only for the synchronous thread to use:\n \t// for sync thread to note its has asked async thread to run\n-\tbool async_started_;\n-\t// counts up to frame_period before restarting the async thread\n-\tint frame_phase_;\n-\tint frame_count_; // counts up to startup_frames\n-\tAwbStatus sync_results_;\n-\tAwbStatus prev_sync_results_;\n-\tstd::string mode_name_;\n+\tbool asyncStarted_;\n+\t// counts up to framePeriod before restarting the async thread\n+\tint framePhase_;\n+\tint frameCount_; // counts up to startup_frames\n+\tAwbStatus syncResults_;\n+\tAwbStatus prevSyncResults_;\n+\tstd::string modeName_;\n \t// The following are for the asynchronous thread to use, though the main\n \t// thread can set/reset them if the async thread is known to be idle:\n \tvoid restartAsync(StatisticsPtr &stats, double lux);\n@@ -141,22 +141,22 @@ private:\n \tStatisticsPtr statistics_;\n \tAwbMode *mode_;\n \tdouble lux_;\n-\tAwbStatus async_results_;\n+\tAwbStatus asyncResults_;\n \tvoid doAwb();\n \tvoid awbBayes();\n \tvoid awbGrey();\n \tvoid prepareStats();\n-\tdouble computeDelta2Sum(double gain_r, double gain_b);\n+\tdouble computeDelta2Sum(double gain_r, double gainB);\n \tPwl interpolatePrior();\n \tdouble coarseSearch(Pwl const &prior);\n \tvoid fineSearch(double &t, double &r, double &b, Pwl const &prior);\n \tstd::vector<RGB> zones_;\n \tstd::vector<Pwl::Point> points_;\n \t// manual r setting\n-\tdouble manual_r_;\n+\tdouble manualR_;\n \t// manual b setting\n-\tdouble manual_b_;\n-\tbool first_switch_mode_; // is this the first call to SwitchMode?\n+\tdouble manualB_;\n+\tbool firstSwitchMode_; // 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", "07/15" ] }