From patchwork Tue Jul 26 12:45:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16777 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 B5ECAC3275 for ; Tue, 26 Jul 2022 12:46:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A03863323; Tue, 26 Jul 2022 14:46:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839564; bh=oEWRyRbyLHxq6LFJOxT8d2X2oKGyLFH3Fzs/ju41rTQ=; 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=B2T3Um7C7gQL+ZTYwyTobOa+HP7ZAfufShS6Xf/RNeK+vcbRca4svBzccXbdQn+rv hmL6jBbikp7oR6bjfHJpVRUTkmRlR6KD6w4C6O7FhqO/KzKwiX5fhIUHEfIXTIi2hl o8dSe1/SCfOJQnbnVvM8aPrb7d8R5sIppNNCu0UK+G6155tVUCLVrFrJYVfIPHGhjc Vqtu5b4TywhNb2ijsk9uw80AZZ/NnSl1p5tKwB9w9coTcXayUwM+mLOGQ2FH1wGj/y gU2Xc2KNOH3X+scKqqmEiqKbPM1KpkTXHZ7gTttoP8Kc0cAW3xxdEdPijEB48Gh0vV hFHEPDGgQm9mQ== Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F21BD63319 for ; Tue, 26 Jul 2022 14:45:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="gBons4uT"; dkim-atps=neutral Received: by mail-wr1-x42e.google.com with SMTP id q18so9567158wrx.8 for ; Tue, 26 Jul 2022 05:45:59 -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=gYLDbh2GP4m2hCvp53O4AJR2v4fto8jA2l+PNoYLPQ8=; b=gBons4uTH79KFYqMo1fcqcnXf8kx9xl8r+rnrjdiduDqiWRM/11Q1g2PAuaQaYW+LL EzV8aA3JrKJCgua+IWx4/ahDqNpfW1fPvrrAO6oLVfJA/mEdQKetfE/K461yivpduLYZ i7QEVhcfaKb6DZFMS9biEPmV1W2RqNN3G4+g3OBxsF1+bGBWyrzOhwUCKeh7/J5dXWGm 0HXheQ111aq5RED7r9tzWsS2R1OTVddwRMPd6mRlY4UJGsFrw3xczxlKELpkvf5FHyza qxvr/zF67HnUvFvuxW1RN9mYhVjQ+/zlcP0X4/u0COa6zFfDi3EALdsL3zmHL2WtxZAl DWXg== 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=gYLDbh2GP4m2hCvp53O4AJR2v4fto8jA2l+PNoYLPQ8=; b=NvhlkeIlvw5Vy5Q7DdSWyVU7Ap3mPCEY9i4OXzyPua8FR2Qdb62rEMiNukzyEOdqCR w/42iHNFduxiGxzgo46/jA8U7PLHWa4fTt7CfyojKE5sYPl9VCELIiBddSaXo8RT/A3H kzccQI/7jTycv9DjWDoSkfrJGKe7SX6YZQTVZ0CCcUNy7a/j+PG0l+nu1md+8+F6iD3f 2mt11j82UvhGIBofRzGjjY18OvwouBHwBQv5M4YLyZjBnIeJGiFdiQQ2R0p80Pe9TOwP BQHa5iWCnwoPuIxVudZnOXI42bCaR1c+pkpjN6lskdLyIo7kWrzwQvn20CH2RuHhJSP2 V+Nw== X-Gm-Message-State: AJIora+6hzs/MFcslIdPTV3yPplfQiIXU7CTM+RIa7jofdtol8PtQOg3 jcHhAavZtXn+egX1To6GE91odnImIPRGQQ== X-Google-Smtp-Source: AGRyM1s2wu5irgG03/3lZkbUjulq/hnA5c588n2wQsLXe8g0IO324+92IHtzrJ0FkFDySBfzXNT9zQ== X-Received: by 2002:a5d:6850:0:b0:21e:6194:acb8 with SMTP id o16-20020a5d6850000000b0021e6194acb8mr10828045wrw.499.1658839558861; Tue, 26 Jul 2022 05:45:58 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id y17-20020adfd091000000b0021e87ec980bsm5948460wrh.84.2022.07.26.05.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:45:58 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:36 +0100 Message-Id: <20220726124549.1646-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220726124549.1646-1-naush@raspberrypi.com> References: <20220726124549.1646-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 04/17] 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 under src/ipa/raspberrypi/controller/c* 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/camera_mode.h | 16 ++-- .../raspberrypi/controller/ccm_algorithm.hpp | 2 +- .../controller/contrast_algorithm.hpp | 4 +- src/ipa/raspberrypi/controller/controller.cpp | 74 ++++++++++--------- src/ipa/raspberrypi/controller/controller.hpp | 22 +++--- 5 files changed, 60 insertions(+), 58 deletions(-) diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h index e2b82828d4b6..8b81ca9df725 100644 --- a/src/ipa/raspberrypi/controller/camera_mode.h +++ b/src/ipa/raspberrypi/controller/camera_mode.h @@ -26,21 +26,21 @@ struct CameraMode { // size in pixels of frames in this mode uint16_t width, height; // size of full resolution uncropped frame ("sensor frame") - uint16_t sensor_width, sensor_height; + uint16_t sensorWidth, sensorHeight; // binning factor (1 = no binning, 2 = 2-pixel binning etc.) - uint8_t bin_x, bin_y; + uint8_t binX, binY; // location of top left pixel in the sensor frame - uint16_t crop_x, crop_y; - // scaling factor (so if uncropped, width*scale_x is sensor_width) - double scale_x, scale_y; + uint16_t cropX, cropY; + // scaling factor (so if uncropped, width*scaleX is sensorWidth) + double scaleX, scaleY; // scaling of the noise compared to the native sensor mode - double noise_factor; + double noiseFactor; // line time - libcamera::utils::Duration line_length; + libcamera::utils::Duration lineLength; // any camera transform *not* reflected already in the camera tuning libcamera::Transform transform; // minimum and maximum fame lengths in units of lines - uint32_t min_frame_length, max_frame_length; + uint32_t minFrameLength, maxFrameLength; // sensitivity of this mode double sensitivity; }; diff --git a/src/ipa/raspberrypi/controller/ccm_algorithm.hpp b/src/ipa/raspberrypi/controller/ccm_algorithm.hpp index 33d0e30dc856..b8b5879ba99c 100644 --- a/src/ipa/raspberrypi/controller/ccm_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/ccm_algorithm.hpp @@ -15,7 +15,7 @@ class CcmAlgorithm : public Algorithm public: CcmAlgorithm(Controller *controller) : Algorithm(controller) {} // A CCM algorithm must provide the following: - virtual void SetSaturation(double saturation) = 0; + virtual void setSaturation(double saturation) = 0; }; } // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/contrast_algorithm.hpp b/src/ipa/raspberrypi/controller/contrast_algorithm.hpp index 7f03bba52844..c76f3cd759ba 100644 --- a/src/ipa/raspberrypi/controller/contrast_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/contrast_algorithm.hpp @@ -15,8 +15,8 @@ class ContrastAlgorithm : public Algorithm public: ContrastAlgorithm(Controller *controller) : Algorithm(controller) {} // A contrast algorithm must provide the following: - virtual void SetBrightness(double brightness) = 0; - virtual void SetContrast(double contrast) = 0; + virtual void setBrightness(double brightness) = 0; + virtual void setContrast(double contrast) = 0; }; } // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/controller.cpp b/src/ipa/raspberrypi/controller/controller.cpp index d3433ad2e7e8..e0b152c74384 100644 --- a/src/ipa/raspberrypi/controller/controller.cpp +++ b/src/ipa/raspberrypi/controller/controller.cpp @@ -19,85 +19,87 @@ using namespace libcamera; LOG_DEFINE_CATEGORY(RPiController) Controller::Controller() - : switch_mode_called_(false) {} + : switchModeCalled_(false) +{ +} -Controller::Controller(char const *json_filename) - : switch_mode_called_(false) +Controller::Controller(char const *jsonFilename) + : switchModeCalled_(false) { - Read(json_filename); - Initialise(); + read(jsonFilename); + initialise(); } Controller::~Controller() {} -void Controller::Read(char const *filename) +void Controller::read(char const *filename) { boost::property_tree::ptree root; boost::property_tree::read_json(filename, root); - for (auto const &key_and_value : root) { - Algorithm *algo = CreateAlgorithm(key_and_value.first.c_str()); + for (auto const &keyAndValue : root) { + Algorithm *algo = createAlgorithm(keyAndValue.first.c_str()); if (algo) { - algo->Read(key_and_value.second); + algo->read(keyAndValue.second); algorithms_.push_back(AlgorithmPtr(algo)); } else LOG(RPiController, Warning) - << "No algorithm found for \"" << key_and_value.first << "\""; + << "No algorithm found for \"" << keyAndValue.first << "\""; } } -Algorithm *Controller::CreateAlgorithm(char const *name) +Algorithm *Controller::createAlgorithm(char const *name) { - auto it = GetAlgorithms().find(std::string(name)); - return it != GetAlgorithms().end() ? (*it->second)(this) : nullptr; + auto it = getAlgorithms().find(std::string(name)); + return it != getAlgorithms().end() ? (*it->second)(this) : nullptr; } -void Controller::Initialise() +void Controller::initialise() { for (auto &algo : algorithms_) - algo->Initialise(); + algo->initialise(); } -void Controller::SwitchMode(CameraMode const &camera_mode, Metadata *metadata) +void Controller::switchMode(CameraMode const &cameraMode, Metadata *metadata) { for (auto &algo : algorithms_) - algo->SwitchMode(camera_mode, metadata); - switch_mode_called_ = true; + algo->switchMode(cameraMode, metadata); + switchModeCalled_ = true; } -void Controller::Prepare(Metadata *image_metadata) +void Controller::prepare(Metadata *imageMetadata) { - assert(switch_mode_called_); + assert(switchModeCalled_); for (auto &algo : algorithms_) - if (!algo->IsPaused()) - algo->Prepare(image_metadata); + if (!algo->isPaused()) + algo->prepare(imageMetadata); } -void Controller::Process(StatisticsPtr stats, Metadata *image_metadata) +void Controller::process(StatisticsPtr stats, Metadata *imageMetadata) { - assert(switch_mode_called_); + assert(switchModeCalled_); for (auto &algo : algorithms_) - if (!algo->IsPaused()) - algo->Process(stats, image_metadata); + if (!algo->isPaused()) + algo->process(stats, imageMetadata); } -Metadata &Controller::GetGlobalMetadata() +Metadata &Controller::getGlobalMetadata() { - return global_metadata_; + return globalMetadata_; } -Algorithm *Controller::GetAlgorithm(std::string const &name) const +Algorithm *Controller::getAlgorithm(std::string const &name) const { // The passed name must be the entire algorithm name, or must match the // last part of it with a period (.) just before. - size_t name_len = name.length(); + size_t nameLen = name.length(); for (auto &algo : algorithms_) { - char const *algo_name = algo->Name(); - size_t algo_name_len = strlen(algo_name); - if (algo_name_len >= name_len && + char const *algoName = algo->name(); + size_t algoNameLen = strlen(algoName); + if (algoNameLen >= nameLen && strcasecmp(name.c_str(), - algo_name + algo_name_len - name_len) == 0 && - (name_len == algo_name_len || - algo_name[algo_name_len - name_len - 1] == '.')) + algoName + algoNameLen - nameLen) == 0 && + (nameLen == algoNameLen || + algoName[algoNameLen - nameLen - 1] == '.')) return algo.get(); } return nullptr; diff --git a/src/ipa/raspberrypi/controller/controller.hpp b/src/ipa/raspberrypi/controller/controller.hpp index 3b50ae770d11..a5e1eb38ab9d 100644 --- a/src/ipa/raspberrypi/controller/controller.hpp +++ b/src/ipa/raspberrypi/controller/controller.hpp @@ -34,21 +34,21 @@ class Controller { public: Controller(); - Controller(char const *json_filename); + Controller(char const *jsonFilename); ~Controller(); - Algorithm *CreateAlgorithm(char const *name); - void Read(char const *filename); - void Initialise(); - void SwitchMode(CameraMode const &camera_mode, Metadata *metadata); - void Prepare(Metadata *image_metadata); - void Process(StatisticsPtr stats, Metadata *image_metadata); - Metadata &GetGlobalMetadata(); - Algorithm *GetAlgorithm(std::string const &name) const; + Algorithm *createAlgorithm(char const *name); + void read(char const *filename); + void initialise(); + void switchMode(CameraMode const &cameraMode, Metadata *metadata); + void prepare(Metadata *imageMetadata); + void process(StatisticsPtr stats, Metadata *imageMetadata); + Metadata &getGlobalMetadata(); + Algorithm *getAlgorithm(std::string const &name) const; protected: - Metadata global_metadata_; + Metadata globalMetadata_; std::vector algorithms_; - bool switch_mode_called_; + bool switchModeCalled_; }; } // namespace RPiController