From patchwork Mon Jul 25 13:46:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16763 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id AAF73C3275 for ; Mon, 25 Jul 2022 13:46:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5FC1B63325; Mon, 25 Jul 2022 15:46:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658756819; bh=CCyGgB+YxhvG4xAkPWe5sx9cDycCqcY3/2JbgIMiuo4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=O8jVfxKdtUVwuZ79Ec80JygAOpIIO7Oc1mtDlpNPdTQgVoPAbfYUvBtwkYUXn4OG0 q6iXRDowxn0f64vpt04Tpx0Y7Gpar0svFZcY09C/MNvom8dNwz72GMFOfUxUMnli16 gUZByMS4r7DbGZz6wkniDkSNFCVEL4y9ZNHmKCsRY1h0yYPjXJZlK9sYdLYYQHoiew /DAv4k46nlzVY5jl85R8jTlQI9BdnnrTwrf9vMIM9YnVNJBtJIjWKfDPdA50/2r9xF tsDtIKJTj+5x386OJ18YJapH3TmJJckwDpuSIQFx0x+3l/CnAvabegEMEi/gf3otJS Vt8y7URFPB9HA== Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C66E26331B for ; Mon, 25 Jul 2022 15:46:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="SryIVCPr"; dkim-atps=neutral Received: by mail-wm1-x330.google.com with SMTP id j29-20020a05600c1c1d00b003a2fdafdefbso6395927wms.2 for ; Mon, 25 Jul 2022 06:46:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CS8z/a4Vg/9QpxoeDhdG8m9mp8Ky5pivjVp9+vV5WRA=; b=SryIVCPr5ZzljWn17ZfvYfHZ4wFX9FBj121jyh9qKJB6CrQZ8p9MVGa+Tocg0zzqY9 /vqfc/dgMLZfiXc3/imfIyp/xUTjsNomqb1dMczpPLGD+JxGIImKjN5PxrU4tINEH8VY ijEmhZt6ky9sCx4F8jMcD4AjGdpAOHoS3z7qUSRcgJ9guRVjndCsAT77oIV14LnqqKc6 YgE8w4dud2bRVcY3EjrB67zBQc3t8zP3BB/VTpFSVONADQW2V9tWz8C+XT66Na8pOYzG 1rBecu06n59poXmRy5gGYY5YTsSwAe+iEf4aDIgbXuVmk5v6j1Ix9eg7p3JI91mMh5U6 EK7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CS8z/a4Vg/9QpxoeDhdG8m9mp8Ky5pivjVp9+vV5WRA=; b=XxzI7as2uWcCsrruf7Jos29FXTZHBbgOhvmZMSxXbIWw87/1RxV1DM8gwtaZpoz9V4 XytwTxb1oxgnKz8kYGvzyyf4lBqdB3AIPmwCpnmNHhCJPZ7Adi7HrqNSa33DVrNQN9Tg ySA81AW0IeqUSznDYJ/07hshoSHIDmt+xZJreEcpkgXYevK9tiuzkEN7igTcP1agK1lp BfQiY0ph8jUh8XOj+NJ4TC59VuZwXbkDXI3V6i/YM2Mt9kuow2gCqHET6WAy7HUtvNvm BdoAuN8X5HPxvsu3PbmTvi1hrBk/lnS8gpV5iihR2L8ji/xU6FoIBv+lHiJr04N4EU8C gmYQ== X-Gm-Message-State: AJIora86fxLZHicgzK3Jm610QO1N+mb7lElpVucbc2J0Vzt8+yWF/CkT dxeS4dpcgcfz/Gv1rP4Q+F0N2evcE41tdw== X-Google-Smtp-Source: AGRyM1v9AFOkK+3CSsrGWVLMvQYZfCKqoT2HKvLi0C2yCVfFifm87Zq6Y5bESuyGRKxTbERIAEK1lA== X-Received: by 2002:a7b:c442:0:b0:3a3:bdb:e84c with SMTP id l2-20020a7bc442000000b003a30bdbe84cmr8463244wmi.101.1658756811140; Mon, 25 Jul 2022 06:46:51 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id a20-20020a05600c225400b003a32167b8d4sm18054320wmm.13.2022.07.25.06.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 06:46:50 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 25 Jul 2022 14:46:34 +0100 Message-Id: <20220725134639.4572-11-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 Subject: [libcamera-devel] [PATCH 10/15] DNI: ipa: raspberrypi: Code refactoring to match style guidelines X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Refactor the source files src/ipa/raspberrypi/controller/rps/[n|s]* to match the recommended formatting guidelines for the libcamera project. The vast majority of changes in this commit comprise of switching from snake_case to CamelCase, and starting class member functions with a lower case character. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/rpi/noise.cpp | 34 ++++++++--------- src/ipa/raspberrypi/controller/rpi/noise.hpp | 14 +++---- src/ipa/raspberrypi/controller/rpi/sdn.cpp | 32 ++++++++-------- src/ipa/raspberrypi/controller/rpi/sdn.hpp | 10 ++--- .../raspberrypi/controller/rpi/sharpen.cpp | 38 +++++++++---------- .../raspberrypi/controller/rpi/sharpen.hpp | 14 +++---- 6 files changed, 72 insertions(+), 70 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/noise.cpp b/src/ipa/raspberrypi/controller/rpi/noise.cpp index 63cad639f313..d6e4df4192f2 100644 --- a/src/ipa/raspberrypi/controller/rpi/noise.cpp +++ b/src/ipa/raspberrypi/controller/rpi/noise.cpp @@ -22,45 +22,45 @@ LOG_DEFINE_CATEGORY(RPiNoise) #define NAME "rpi.noise" Noise::Noise(Controller *controller) - : Algorithm(controller), mode_factor_(1.0) + : Algorithm(controller), modeFactor_(1.0) { } -char const *Noise::Name() const +char const *Noise::name() const { return NAME; } -void Noise::SwitchMode(CameraMode const &camera_mode, +void Noise::switchMode(CameraMode const &cameraMode, [[maybe_unused]] Metadata *metadata) { // For example, we would expect a 2x2 binned mode to have a "noise // factor" of sqrt(2x2) = 2. (can't be less than one, right?) - mode_factor_ = std::max(1.0, camera_mode.noise_factor); + modeFactor_ = std::max(1.0, cameraMode.noiseFactor); } -void Noise::Read(boost::property_tree::ptree const ¶ms) +void Noise::read(boost::property_tree::ptree const ¶ms) { - reference_constant_ = params.get("reference_constant"); - reference_slope_ = params.get("reference_slope"); + referenceConstant_ = params.get("reference_constant"); + referenceSlope_ = params.get("reference_slope"); } -void Noise::Prepare(Metadata *image_metadata) +void Noise::prepare(Metadata *imageMetadata) { - struct DeviceStatus device_status; - device_status.analogue_gain = 1.0; // keep compiler calm - if (image_metadata->Get("device.status", device_status) == 0) { + struct DeviceStatus deviceStatus; + deviceStatus.analogueGain = 1.0; // keep compiler calm + if (imageMetadata->get("device.status", deviceStatus) == 0) { // There is a slight question as to exactly how the noise // profile, specifically the constant part of it, scales. For // now we assume it all scales the same, and we'll revisit this // if it proves substantially wrong. NOTE: we may also want to // make some adjustments based on the camera mode (such as // binning), if we knew how to discover it... - double factor = sqrt(device_status.analogue_gain) / mode_factor_; + double factor = sqrt(deviceStatus.analogueGain) / modeFactor_; struct NoiseStatus status; - status.noise_constant = reference_constant_ * factor; - status.noise_slope = reference_slope_ * factor; - image_metadata->Set("noise.status", status); + status.noise_constant = referenceConstant_ * factor; + status.noise_slope = referenceSlope_ * factor; + imageMetadata->set("noise.status", status); LOG(RPiNoise, Debug) << "constant " << status.noise_constant << " slope " << status.noise_slope; @@ -69,8 +69,8 @@ void Noise::Prepare(Metadata *image_metadata) } // Register algorithm with the system. -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return new Noise(controller); } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/noise.hpp b/src/ipa/raspberrypi/controller/rpi/noise.hpp index 1c9de5c87d08..ed6ffe910e27 100644 --- a/src/ipa/raspberrypi/controller/rpi/noise.hpp +++ b/src/ipa/raspberrypi/controller/rpi/noise.hpp @@ -17,16 +17,16 @@ class Noise : public Algorithm { public: Noise(Controller *controller); - char const *Name() const override; - void SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override; - void Read(boost::property_tree::ptree const ¶ms) override; - void Prepare(Metadata *image_metadata) override; + char const *name() const override; + void switchMode(CameraMode const &cameraMode, Metadata *metadata) override; + void read(boost::property_tree::ptree const ¶ms) override; + void prepare(Metadata *imageMetadata) override; private: // the noise profile for analogue gain of 1.0 - double reference_constant_; - double reference_slope_; - double mode_factor_; + double referenceConstant_; + double referenceSlope_; + double modeFactor_; }; } // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.cpp b/src/ipa/raspberrypi/controller/rpi/sdn.cpp index 9384550983e7..8707b6d9cd9e 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.cpp @@ -27,49 +27,51 @@ Sdn::Sdn(Controller *controller) { } -char const *Sdn::Name() const +char const *Sdn::name() const { return NAME; } -void Sdn::Read(boost::property_tree::ptree const ¶ms) +void Sdn::read(boost::property_tree::ptree const ¶ms) { deviation_ = params.get("deviation", 3.2); strength_ = params.get("strength", 0.75); } -void Sdn::Initialise() {} +void Sdn::initialise() +{ +} -void Sdn::Prepare(Metadata *image_metadata) +void Sdn::prepare(Metadata *imageMetadata) { - struct NoiseStatus noise_status = {}; - noise_status.noise_slope = 3.0; // in case no metadata - if (image_metadata->Get("noise.status", noise_status) != 0) + struct NoiseStatus noiseStatus = {}; + noiseStatus.noise_slope = 3.0; // in case no metadata + if (imageMetadata->get("noise.status", noiseStatus) != 0) LOG(RPiSdn, Warning) << "no noise profile found"; LOG(RPiSdn, Debug) - << "Noise profile: constant " << noise_status.noise_constant - << " slope " << noise_status.noise_slope; + << "Noise profile: constant " << noiseStatus.noise_constant + << " slope " << noiseStatus.noise_slope; struct DenoiseStatus status; - status.noise_constant = noise_status.noise_constant * deviation_; - status.noise_slope = noise_status.noise_slope * deviation_; + status.noise_constant = noiseStatus.noise_constant * deviation_; + status.noise_slope = noiseStatus.noise_slope * deviation_; status.strength = strength_; status.mode = static_cast>(mode_); - image_metadata->Set("denoise.status", status); + imageMetadata->set("denoise.status", status); LOG(RPiSdn, Debug) << "programmed constant " << status.noise_constant << " slope " << status.noise_slope << " strength " << status.strength; } -void Sdn::SetMode(DenoiseMode mode) +void Sdn::setMode(DenoiseMode mode) { // We only distinguish between off and all other modes. mode_ = mode; } // Register algorithm with the system. -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return (Algorithm *)new Sdn(controller); } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.hpp b/src/ipa/raspberrypi/controller/rpi/sdn.hpp index 2371ce04163f..d9b18f296635 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.hpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.hpp @@ -17,11 +17,11 @@ class Sdn : public DenoiseAlgorithm { public: Sdn(Controller *controller = NULL); - char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; - void Initialise() override; - void Prepare(Metadata *image_metadata) override; - void SetMode(DenoiseMode mode) override; + char const *name() const override; + void read(boost::property_tree::ptree const ¶ms) override; + void initialise() override; + void prepare(Metadata *imageMetadata) override; + void setMode(DenoiseMode mode) override; private: double deviation_; diff --git a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp index 18825a43867b..775ed0fd2c46 100644 --- a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp @@ -21,23 +21,23 @@ LOG_DEFINE_CATEGORY(RPiSharpen) #define NAME "rpi.sharpen" Sharpen::Sharpen(Controller *controller) - : SharpenAlgorithm(controller), user_strength_(1.0) + : SharpenAlgorithm(controller), userStrength_(1.0) { } -char const *Sharpen::Name() const +char const *Sharpen::name() const { return NAME; } -void Sharpen::SwitchMode(CameraMode const &camera_mode, +void Sharpen::switchMode(CameraMode const &cameraMode, [[maybe_unused]] Metadata *metadata) { // can't be less than one, right? - mode_factor_ = std::max(1.0, camera_mode.noise_factor); + modeFactor_ = std::max(1.0, cameraMode.noiseFactor); } -void Sharpen::Read(boost::property_tree::ptree const ¶ms) +void Sharpen::read(boost::property_tree::ptree const ¶ms) { threshold_ = params.get("threshold", 1.0); strength_ = params.get("strength", 1.0); @@ -48,38 +48,38 @@ void Sharpen::Read(boost::property_tree::ptree const ¶ms) << " limit " << limit_; } -void Sharpen::SetStrength(double strength) +void Sharpen::setStrength(double strength) { // Note that this function is how an application sets the overall // sharpening "strength". We call this the "user strength" field // as there already is a strength_ field - being an internal gain // parameter that gets passed to the ISP control code. Negative // values are not allowed - coerce them to zero (no sharpening). - user_strength_ = std::max(0.0, strength); + userStrength_ = std::max(0.0, strength); } -void Sharpen::Prepare(Metadata *image_metadata) +void Sharpen::prepare(Metadata *imageMetadata) { // The user_strength_ affects the algorithm's internal gain directly, but // we adjust the limit and threshold less aggressively. Using a sqrt // function is an arbitrary but gentle way of accomplishing this. - double user_strength_sqrt = sqrt(user_strength_); + double userStrengthSqrt = sqrt(userStrength_); struct SharpenStatus status; // Binned modes seem to need the sharpening toned down with this // pipeline, thus we use the mode_factor here. Also avoid - // divide-by-zero with the user_strength_sqrt. - status.threshold = threshold_ * mode_factor_ / - std::max(0.01, user_strength_sqrt); - status.strength = strength_ / mode_factor_ * user_strength_; - status.limit = limit_ / mode_factor_ * user_strength_sqrt; - // Finally, report any application-supplied parameters that were used. - status.user_strength = user_strength_; - image_metadata->Set("sharpen.status", status); + // divide-by-zero with the userStrengthSqrt. + status.threshold = threshold_ * modeFactor_ / + std::max(0.01, userStrengthSqrt); + status.strength = strength_ / modeFactor_ * userStrength_; + status.limit = limit_ / modeFactor_ * userStrengthSqrt; + /* Finally, report any application-supplied parameters that were used. */ + status.userStrength = userStrength_; + imageMetadata->set("sharpen.status", status); } // Register algorithm with the system. -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return new Sharpen(controller); } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/sharpen.hpp b/src/ipa/raspberrypi/controller/rpi/sharpen.hpp index 13a076a86895..ced917f3c42b 100644 --- a/src/ipa/raspberrypi/controller/rpi/sharpen.hpp +++ b/src/ipa/raspberrypi/controller/rpi/sharpen.hpp @@ -17,18 +17,18 @@ class Sharpen : public SharpenAlgorithm { public: Sharpen(Controller *controller); - char const *Name() const override; - void SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override; - void Read(boost::property_tree::ptree const ¶ms) override; - void SetStrength(double strength) override; - void Prepare(Metadata *image_metadata) override; + char const *name() const override; + void switchMode(CameraMode const &cameraMode, Metadata *metadata) override; + void read(boost::property_tree::ptree const ¶ms) override; + void setStrength(double strength) override; + void prepare(Metadata *imageMetadata) override; private: double threshold_; double strength_; double limit_; - double mode_factor_; - double user_strength_; + double modeFactor_; + double userStrength_; }; } // namespace RPiController