From patchwork Tue Jul 26 12:45:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16774 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 6E9A2C3275 for ; Tue, 26 Jul 2022 12:46:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 831B963317; Tue, 26 Jul 2022 14:45:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839559; bh=My4qxnyMZp0PwrV1myytSX52rkJbuun8Nf3Ub9QaA7o=; 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=m4k/Ntxld/sL1Sxyh8wqWTCirDLOKzoH5gM6g02lhiX7ARkv2qfIujZb7ev+lYAdJ TZHDmz6qvlkkjyzixzF3H/XCwjh+bUFBnNzxPJduvoLeAc47p1Cx2+DIHu6xHKZ4Ei eHUr6PpORCZNyQC4CrEnj16O/hAXI7AojdOTdrNM/nb7BAZxit0sfX2NV7t8ppvt0y aG99l9GFwO2QpHo5WHzEnNSetHYMO3jmsNA13a/HlmLXLIRNtjS9jHeE+27khzHPOG CLlwwNi0MvvcyMshDNoRJacakCwfD0cbLhQImCLYlf/iE7xgN/EhYfKl8XFmYIaKxA 2CMJSPpjd0MKQ== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AED206330E for ; Tue, 26 Jul 2022 14:45:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="kbkMLOpP"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id k12so2262121wrm.13 for ; Tue, 26 Jul 2022 05:45:56 -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=kKYwVgRcN08N55xcJHFdRUNxd+NLxWz9ywchhdW3jxM=; b=kbkMLOpPc58zrj15k5vdjnLZC8P/9c18X5LMYuqjCPYwSRzjZ8OGa0E9KUHAYKWrHM nMhT/OjbfbY5Vc4EhzgrgrVWNQBjp0dEtV9u+DVEahIvRIyiJnojlM9fqOYX80t59Iem 7Qicjtf7HWLidlVV5wSU/v/qjQDlXlwL99VEWyPaJUWYcRovYcMfoqXfYTKNzhBPyCjo aeA9OCUwpzNA4+uymJhh1tuHnt3xWhlP2C8xPhuUm2M0sOaLhn6nQk4lFdFK2FbCTdNJ LmlfJiEGyO2KLT2PwZV8ng9yniSVFFBmtoT+Keuoz1oEXZw1f+0VbiTwfVok7ZxWGRhA TADw== 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=kKYwVgRcN08N55xcJHFdRUNxd+NLxWz9ywchhdW3jxM=; b=MfVRV+aK3JrEMfotPJDfwCc7cm4Z/EFZDHoi4pjjesQZ47YLbIoXNR7QLDMAKizRL1 4N0w4ihzVKFt2CCWcIj/2fICo9yhfCMBW4tAAtjYX5trd3DML6IMQLuQTZ23ccI1lM0r QlZi52qXZRQQgF5PD+jP68ZN9eVrhecbpFE7AotYFkqO6AcRlhIX0IOzgvlAwLde2RT7 tITlRjB22JC2Qz8oSwhYtJ4O+k+P5us7coRsqzk8hvYS28+LgtRKy1NN64Nv6AP1y7Xo ubgZNfUdStnOmkdvh/Wt2VM4kcfWR9Km/r5CaRv+RjlCX0aSl94WoDbpY30MNY/iP4gz PRdA== X-Gm-Message-State: AJIora+I9M5JFGQ9eR33soOK+89+s/uQfTtUP6Z2XIvmBmok/NKU9Eks llPniEe+JwFHXTqbsbT7u72q7jyXS8mS9g== X-Google-Smtp-Source: AGRyM1tQg6Ptf2IhDkChb5brd+wDDuzrJF6dXxpGY26ieR2pIo8wpHEY3ZAcYjSqlFe4M2kk24RyFg== X-Received: by 2002:a05:6000:887:b0:21e:24a0:f302 with SMTP id ca7-20020a056000088700b0021e24a0f302mr10446541wrb.466.1658839555551; Tue, 26 Jul 2022 05:45:55 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:45:54 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:33 +0100 Message-Id: <20220726124549.1646-2-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 01/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 in src/ipa/raspberrypi/ 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 --- .../controller/sharpen_algorithm.hpp | 2 +- .../raspberrypi/controller/sharpen_status.h | 2 +- src/ipa/raspberrypi/md_parser.hpp | 44 +-- src/ipa/raspberrypi/md_parser_smia.cpp | 108 +++---- src/ipa/raspberrypi/raspberrypi.cpp | 272 +++++++++--------- 5 files changed, 214 insertions(+), 214 deletions(-) diff --git a/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp b/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp index ca800308fd6c..888f4569c56a 100644 --- a/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp @@ -15,7 +15,7 @@ class SharpenAlgorithm : public Algorithm public: SharpenAlgorithm(Controller *controller) : Algorithm(controller) {} // A sharpness control algorithm must provide the following: - virtual void SetStrength(double strength) = 0; + virtual void setStrength(double strength) = 0; }; } // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/sharpen_status.h b/src/ipa/raspberrypi/controller/sharpen_status.h index 7501b191d6f6..2b0490742fba 100644 --- a/src/ipa/raspberrypi/controller/sharpen_status.h +++ b/src/ipa/raspberrypi/controller/sharpen_status.h @@ -20,7 +20,7 @@ struct SharpenStatus { // upper limit of the allowed sharpening response double limit; // The sharpening strength requested by the user or application. - double user_strength; + double userStrength; }; #ifdef __cplusplus diff --git a/src/ipa/raspberrypi/md_parser.hpp b/src/ipa/raspberrypi/md_parser.hpp index d32d0f549b9c..298d51811256 100644 --- a/src/ipa/raspberrypi/md_parser.hpp +++ b/src/ipa/raspberrypi/md_parser.hpp @@ -75,40 +75,40 @@ public: }; MdParser() - : reset_(true), bits_per_pixel_(0), num_lines_(0), line_length_bytes_(0) + : reset_(true), bitsPerPixel_(0), numLines_(0), lineLengthBytes_(0) { } virtual ~MdParser() = default; - void Reset() + void reset() { reset_ = true; } - void SetBitsPerPixel(int bpp) + void setBitsPerPixel(int bpp) { - bits_per_pixel_ = bpp; + bitsPerPixel_ = bpp; } - void SetNumLines(unsigned int num_lines) + void setNumLines(unsigned int numLines) { - num_lines_ = num_lines; + numLines_ = numLines; } - void SetLineLengthBytes(unsigned int num_bytes) + void setLineLengthBytes(unsigned int numBytes) { - line_length_bytes_ = num_bytes; + lineLengthBytes_ = numBytes; } - virtual Status Parse(libcamera::Span buffer, + virtual Status parse(libcamera::Span buffer, RegisterMap ®isters) = 0; protected: bool reset_; - int bits_per_pixel_; - unsigned int num_lines_; - unsigned int line_length_bytes_; + int bitsPerPixel_; + unsigned int numLines_; + unsigned int lineLengthBytes_; }; /* @@ -123,7 +123,7 @@ class MdParserSmia final : public MdParser public: MdParserSmia(std::initializer_list registerList); - MdParser::Status Parse(libcamera::Span buffer, + MdParser::Status parse(libcamera::Span buffer, RegisterMap ®isters) override; private: @@ -133,18 +133,18 @@ private: /* * Note that error codes > 0 are regarded as non-fatal; codes < 0 * indicate a bad data buffer. Status codes are: - * PARSE_OK - found all registers, much happiness - * MISSING_REGS - some registers found; should this be a hard error? + * ParseOk - found all registers, much happiness + * MissingRegs - some registers found; should this be a hard error? * The remaining codes are all hard errors. */ enum ParseStatus { - PARSE_OK = 0, - MISSING_REGS = 1, - NO_LINE_START = -1, - ILLEGAL_TAG = -2, - BAD_DUMMY = -3, - BAD_LINE_END = -4, - BAD_PADDING = -5 + ParseOk = 0, + MissingRegs = 1, + NoLineStart = -1, + IllegalTag = -2, + BadDummy = -3, + BadLineEnd = -4, + BadPadding = -5 }; ParseStatus findRegs(libcamera::Span buffer); diff --git a/src/ipa/raspberrypi/md_parser_smia.cpp b/src/ipa/raspberrypi/md_parser_smia.cpp index ea5eac414b36..9fab6594baac 100644 --- a/src/ipa/raspberrypi/md_parser_smia.cpp +++ b/src/ipa/raspberrypi/md_parser_smia.cpp @@ -20,12 +20,12 @@ using namespace libcamera; * sensors, I think. */ -constexpr unsigned int LINE_START = 0x0a; -constexpr unsigned int LINE_END_TAG = 0x07; -constexpr unsigned int REG_HI_BITS = 0xaa; -constexpr unsigned int REG_LOW_BITS = 0xa5; -constexpr unsigned int REG_VALUE = 0x5a; -constexpr unsigned int REG_SKIP = 0x55; +constexpr unsigned int LineStart = 0x0a; +constexpr unsigned int LineEndTag = 0x07; +constexpr unsigned int RegHiBits = 0xaa; +constexpr unsigned int RegLowBits = 0xa5; +constexpr unsigned int RegValue = 0x5a; +constexpr unsigned int RegSkip = 0x55; MdParserSmia::MdParserSmia(std::initializer_list registerList) { @@ -33,7 +33,7 @@ MdParserSmia::MdParserSmia(std::initializer_list registerList) offsets_[r] = {}; } -MdParser::Status MdParserSmia::Parse(libcamera::Span buffer, +MdParser::Status MdParserSmia::parse(libcamera::Span buffer, RegisterMap ®isters) { if (reset_) { @@ -41,7 +41,7 @@ MdParser::Status MdParserSmia::Parse(libcamera::Span buffer, * Search again through the metadata for all the registers * requested. */ - ASSERT(bits_per_pixel_); + ASSERT(bitsPerPixel_); for (const auto &kv : offsets_) offsets_[kv.first] = {}; @@ -53,7 +53,7 @@ MdParser::Status MdParserSmia::Parse(libcamera::Span buffer, * * In either case, we retry parsing on the next frame. */ - if (ret != PARSE_OK) + if (ret != ParseOk) return ERROR; reset_ = false; @@ -76,74 +76,74 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span { ASSERT(offsets_.size()); - if (buffer[0] != LINE_START) - return NO_LINE_START; + if (buffer[0] != LineStart) + return NoLineStart; - unsigned int current_offset = 1; /* after the LINE_START */ - unsigned int current_line_start = 0, current_line = 0; - unsigned int reg_num = 0, regs_done = 0; + unsigned int currentOffset = 1; /* after the LineStart */ + unsigned int currentLineStart = 0, currentLine = 0; + unsigned int regNum = 0, regsDone = 0; while (1) { - int tag = buffer[current_offset++]; - - if ((bits_per_pixel_ == 10 && - (current_offset + 1 - current_line_start) % 5 == 0) || - (bits_per_pixel_ == 12 && - (current_offset + 1 - current_line_start) % 3 == 0)) { - if (buffer[current_offset++] != REG_SKIP) - return BAD_DUMMY; + int tag = buffer[currentOffset++]; + + if ((bitsPerPixel_ == 10 && + (currentOffset + 1 - currentLineStart) % 5 == 0) || + (bitsPerPixel_ == 12 && + (currentOffset + 1 - currentLineStart) % 3 == 0)) { + if (buffer[currentOffset++] != RegSkip) + return BadDummy; } - int data_byte = buffer[current_offset++]; + int dataByte = buffer[currentOffset++]; - if (tag == LINE_END_TAG) { - if (data_byte != LINE_END_TAG) - return BAD_LINE_END; + if (tag == LineEndTag) { + if (dataByte != LineEndTag) + return BadLineEnd; - if (num_lines_ && ++current_line == num_lines_) - return MISSING_REGS; + if (numLines_ && ++currentLine == numLines_) + return MissingRegs; - if (line_length_bytes_) { - current_offset = current_line_start + line_length_bytes_; + if (lineLengthBytes_) { + currentOffset = currentLineStart + lineLengthBytes_; /* Require whole line to be in the buffer (if buffer size set). */ if (buffer.size() && - current_offset + line_length_bytes_ > buffer.size()) - return MISSING_REGS; + currentOffset + lineLengthBytes_ > buffer.size()) + return MissingRegs; - if (buffer[current_offset] != LINE_START) - return NO_LINE_START; + if (buffer[currentOffset] != LineStart) + return NoLineStart; } else { /* allow a zero line length to mean "hunt for the next line" */ - while (current_offset < buffer.size() && - buffer[current_offset] != LINE_START) - current_offset++; + while (currentOffset < buffer.size() && + buffer[currentOffset] != LineStart) + currentOffset++; - if (current_offset == buffer.size()) - return NO_LINE_START; + if (currentOffset == buffer.size()) + return NoLineStart; } - /* inc current_offset to after LINE_START */ - current_line_start = current_offset++; + /* inc current_offset to after LineStart */ + currentLineStart = currentOffset++; } else { - if (tag == REG_HI_BITS) - reg_num = (reg_num & 0xff) | (data_byte << 8); - else if (tag == REG_LOW_BITS) - reg_num = (reg_num & 0xff00) | data_byte; - else if (tag == REG_SKIP) - reg_num++; - else if (tag == REG_VALUE) { - auto reg = offsets_.find(reg_num); + if (tag == RegHiBits) + regNum = (regNum & 0xff) | (dataByte << 8); + else if (tag == RegLowBits) + regNum = (regNum & 0xff00) | dataByte; + else if (tag == RegSkip) + regNum++; + else if (tag == RegValue) { + auto reg = offsets_.find(regNum); if (reg != offsets_.end()) { - offsets_[reg_num] = current_offset - 1; + offsets_[regNum] = currentOffset - 1; - if (++regs_done == offsets_.size()) - return PARSE_OK; + if (++regsDone == offsets_.size()) + return ParseOk; } - reg_num++; + regNum++; } else - return ILLEGAL_TAG; + return IllegalTag; } } } diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index c7492a77a3fd..f315ebcd4c6b 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -208,7 +208,7 @@ int IPARPi::init(const IPASettings &settings, IPAInitResult *result) * that the kernel driver doesn't. We only do this the first time; we don't need * to re-parse the metadata after a simple mode-switch for no reason. */ - helper_ = std::unique_ptr(RPiController::CamHelper::Create(settings.sensorModel)); + helper_ = std::unique_ptr(RPiController::CamHelper::create(settings.sensorModel)); if (!helper_) { LOG(IPARPI, Error) << "Could not create camera helper for " << settings.sensorModel; @@ -220,8 +220,8 @@ int IPARPi::init(const IPASettings &settings, IPAInitResult *result) * to setup the staggered writer class. */ int gainDelay, exposureDelay, vblankDelay, sensorMetadata; - helper_->GetDelays(exposureDelay, gainDelay, vblankDelay); - sensorMetadata = helper_->SensorEmbeddedDataPresent(); + helper_->getDelays(exposureDelay, gainDelay, vblankDelay); + sensorMetadata = helper_->sensorEmbeddedDataPresent(); result->sensorConfig.gainDelay = gainDelay; result->sensorConfig.exposureDelay = exposureDelay; @@ -229,8 +229,8 @@ int IPARPi::init(const IPASettings &settings, IPAInitResult *result) result->sensorConfig.sensorMetadata = sensorMetadata; /* Load the tuning file for this sensor. */ - controller_.Read(settings.configurationFile.c_str()); - controller_.Initialise(); + controller_.read(settings.configurationFile.c_str()); + controller_.initialise(); /* Return the controls handled by the IPA */ ControlInfoMap::Map ctrlMap = ipaControls; @@ -249,15 +249,15 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) queueRequest(controls); } - controller_.SwitchMode(mode_, &metadata); + controller_.switchMode(mode_, &metadata); /* SwitchMode may supply updated exposure/gain values to use. */ AgcStatus agcStatus; - agcStatus.shutter_time = 0.0s; - agcStatus.analogue_gain = 0.0; + agcStatus.shutterTime = 0.0s; + agcStatus.analogueGain = 0.0; - metadata.Get("agc.status", agcStatus); - if (agcStatus.shutter_time && agcStatus.analogue_gain) { + metadata.get("agc.status", agcStatus); + if (agcStatus.shutterTime && agcStatus.analogueGain) { ControlList ctrls(sensorCtrls_); applyAGC(&agcStatus, ctrls); startConfig->controls = std::move(ctrls); @@ -271,8 +271,8 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) frameCount_ = 0; checkCount_ = 0; if (firstStart_) { - dropFrameCount_ = helper_->HideFramesStartup(); - mistrustCount_ = helper_->MistrustFramesStartup(); + dropFrameCount_ = helper_->hideFramesStartup(); + mistrustCount_ = helper_->mistrustFramesStartup(); /* * Query the AGC/AWB for how many frames they may take to @@ -283,18 +283,18 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) */ unsigned int agcConvergenceFrames = 0; RPiController::AgcAlgorithm *agc = dynamic_cast( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (agc) { - agcConvergenceFrames = agc->GetConvergenceFrames(); + agcConvergenceFrames = agc->getConvergenceFrames(); if (agcConvergenceFrames) agcConvergenceFrames += mistrustCount_; } unsigned int awbConvergenceFrames = 0; RPiController::AwbAlgorithm *awb = dynamic_cast( - controller_.GetAlgorithm("awb")); + controller_.getAlgorithm("awb")); if (awb) { - awbConvergenceFrames = awb->GetConvergenceFrames(); + awbConvergenceFrames = awb->getConvergenceFrames(); if (awbConvergenceFrames) awbConvergenceFrames += mistrustCount_; } @@ -302,12 +302,12 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) dropFrameCount_ = std::max({ dropFrameCount_, agcConvergenceFrames, awbConvergenceFrames }); LOG(IPARPI, Debug) << "Drop " << dropFrameCount_ << " frames on startup"; } else { - dropFrameCount_ = helper_->HideFramesModeSwitch(); - mistrustCount_ = helper_->MistrustFramesModeSwitch(); + dropFrameCount_ = helper_->hideFramesModeSwitch(); + mistrustCount_ = helper_->mistrustFramesModeSwitch(); } startConfig->dropFrameCount = dropFrameCount_; - const Duration maxSensorFrameDuration = mode_.max_frame_length * mode_.line_length; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; startConfig->maxSensorFrameLengthMs = maxSensorFrameDuration.get(); firstStart_ = false; @@ -319,17 +319,17 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) mode_.bitdepth = sensorInfo.bitsPerPixel; mode_.width = sensorInfo.outputSize.width; mode_.height = sensorInfo.outputSize.height; - mode_.sensor_width = sensorInfo.activeAreaSize.width; - mode_.sensor_height = sensorInfo.activeAreaSize.height; - mode_.crop_x = sensorInfo.analogCrop.x; - mode_.crop_y = sensorInfo.analogCrop.y; + mode_.sensorWidth = sensorInfo.activeAreaSize.width; + mode_.sensorHeight = sensorInfo.activeAreaSize.height; + mode_.cropX = sensorInfo.analogCrop.x; + mode_.cropY = sensorInfo.analogCrop.y; /* * Calculate scaling parameters. The scale_[xy] factors are determined * by the ratio between the crop rectangle size and the output size. */ - mode_.scale_x = sensorInfo.analogCrop.width / sensorInfo.outputSize.width; - mode_.scale_y = sensorInfo.analogCrop.height / sensorInfo.outputSize.height; + mode_.scaleX = sensorInfo.analogCrop.width / sensorInfo.outputSize.width; + mode_.scaleY = sensorInfo.analogCrop.height / sensorInfo.outputSize.height; /* * We're not told by the pipeline handler how scaling is split between @@ -339,30 +339,30 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) * * \todo Get the pipeline handle to provide the full data */ - mode_.bin_x = std::min(2, static_cast(mode_.scale_x)); - mode_.bin_y = std::min(2, static_cast(mode_.scale_y)); + mode_.binX = std::min(2, static_cast(mode_.scaleX)); + mode_.binY = std::min(2, static_cast(mode_.scaleY)); /* The noise factor is the square root of the total binning factor. */ - mode_.noise_factor = sqrt(mode_.bin_x * mode_.bin_y); + mode_.noiseFactor = sqrt(mode_.binX * mode_.binY); /* * Calculate the line length as the ratio between the line length in * pixels and the pixel rate. */ - mode_.line_length = sensorInfo.lineLength * (1.0s / sensorInfo.pixelRate); + mode_.lineLength = sensorInfo.lineLength * (1.0s / sensorInfo.pixelRate); /* * Set the frame length limits for the mode to ensure exposure and * framerate calculations are clipped appropriately. */ - mode_.min_frame_length = sensorInfo.minFrameLength; - mode_.max_frame_length = sensorInfo.maxFrameLength; + mode_.minFrameLength = sensorInfo.minFrameLength; + mode_.maxFrameLength = sensorInfo.maxFrameLength; /* * Some sensors may have different sensitivities in different modes; * the CamHelper will know the correct value. */ - mode_.sensitivity = helper_->GetModeSensitivity(mode_); + mode_.sensitivity = helper_->getModeSensitivity(mode_); } int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, @@ -421,7 +421,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, } /* Pass the camera mode to the CamHelper to setup algorithms. */ - helper_->SetCameraMode(mode_); + helper_->setCameraMode(mode_); /* * Initialise this ControlList correctly, even if empty, in case the IPA is @@ -438,8 +438,8 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, /* Supply initial values for gain and exposure. */ AgcStatus agcStatus; - agcStatus.shutter_time = defaultExposureTime; - agcStatus.analogue_gain = defaultAnalogueGain; + agcStatus.shutterTime = defaultExposureTime; + agcStatus.analogueGain = defaultAnalogueGain; applyAGC(&agcStatus, ctrls); } @@ -451,25 +451,25 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, * based on the current sensor mode. */ ControlInfoMap::Map ctrlMap = ipaControls; - const Duration minSensorFrameDuration = mode_.min_frame_length * mode_.line_length; - const Duration maxSensorFrameDuration = mode_.max_frame_length * mode_.line_length; + const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.lineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; ctrlMap[&controls::FrameDurationLimits] = ControlInfo(static_cast(minSensorFrameDuration.get()), static_cast(maxSensorFrameDuration.get())); ctrlMap[&controls::AnalogueGain] = - ControlInfo(1.0f, static_cast(helper_->Gain(maxSensorGainCode_))); + ControlInfo(1.0f, static_cast(helper_->gain(maxSensorGainCode_))); /* * Calculate the max exposure limit from the frame duration limit as V4L2 * will limit the maximum control value based on the current VBLANK value. */ Duration maxShutter = Duration::max(); - helper_->GetVBlanking(maxShutter, minSensorFrameDuration, maxSensorFrameDuration); + helper_->getVBlanking(maxShutter, minSensorFrameDuration, maxSensorFrameDuration); const uint32_t exposureMin = sensorCtrls_.at(V4L2_CID_EXPOSURE).min().get(); ctrlMap[&controls::ExposureTime] = - ControlInfo(static_cast(helper_->Exposure(exposureMin).get()), + ControlInfo(static_cast(helper_->exposure(exposureMin).get()), static_cast(maxShutter.get())); result->controlInfo = ControlInfoMap(std::move(ctrlMap), controls::controls); @@ -536,54 +536,54 @@ void IPARPi::reportMetadata() * processed can be extracted and placed into the libcamera metadata * buffer, where an application could query it. */ - DeviceStatus *deviceStatus = rpiMetadata_.GetLocked("device.status"); + DeviceStatus *deviceStatus = rpiMetadata_.getLocked("device.status"); if (deviceStatus) { libcameraMetadata_.set(controls::ExposureTime, - deviceStatus->shutter_speed.get()); - libcameraMetadata_.set(controls::AnalogueGain, deviceStatus->analogue_gain); + deviceStatus->shutterSpeed.get()); + libcameraMetadata_.set(controls::AnalogueGain, deviceStatus->analogueGain); libcameraMetadata_.set(controls::FrameDuration, - helper_->Exposure(deviceStatus->frame_length).get()); - if (deviceStatus->sensor_temperature) - libcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensor_temperature); + helper_->exposure(deviceStatus->frameLength).get()); + if (deviceStatus->sensorTemperature) + libcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensorTemperature); } - AgcStatus *agcStatus = rpiMetadata_.GetLocked("agc.status"); + AgcStatus *agcStatus = rpiMetadata_.getLocked("agc.status"); if (agcStatus) { libcameraMetadata_.set(controls::AeLocked, agcStatus->locked); - libcameraMetadata_.set(controls::DigitalGain, agcStatus->digital_gain); + libcameraMetadata_.set(controls::DigitalGain, agcStatus->digitalGain); } - LuxStatus *luxStatus = rpiMetadata_.GetLocked("lux.status"); + LuxStatus *luxStatus = rpiMetadata_.getLocked("lux.status"); if (luxStatus) libcameraMetadata_.set(controls::Lux, luxStatus->lux); - AwbStatus *awbStatus = rpiMetadata_.GetLocked("awb.status"); + AwbStatus *awbStatus = rpiMetadata_.getLocked("awb.status"); if (awbStatus) { - libcameraMetadata_.set(controls::ColourGains, { static_cast(awbStatus->gain_r), - static_cast(awbStatus->gain_b) }); - libcameraMetadata_.set(controls::ColourTemperature, awbStatus->temperature_K); + libcameraMetadata_.set(controls::ColourGains, { static_cast(awbStatus->gainR), + static_cast(awbStatus->gainB) }); + libcameraMetadata_.set(controls::ColourTemperature, awbStatus->temperatureK); } - BlackLevelStatus *blackLevelStatus = rpiMetadata_.GetLocked("black_level.status"); + BlackLevelStatus *blackLevelStatus = rpiMetadata_.getLocked("black_level.status"); if (blackLevelStatus) libcameraMetadata_.set(controls::SensorBlackLevels, - { static_cast(blackLevelStatus->black_level_r), - static_cast(blackLevelStatus->black_level_g), - static_cast(blackLevelStatus->black_level_g), - static_cast(blackLevelStatus->black_level_b) }); + { static_cast(blackLevelStatus->blackLevelR), + static_cast(blackLevelStatus->blackLevelG), + static_cast(blackLevelStatus->blackLevelG), + static_cast(blackLevelStatus->blackLevelB) }); - FocusStatus *focusStatus = rpiMetadata_.GetLocked("focus.status"); + FocusStatus *focusStatus = rpiMetadata_.getLocked("focus.status"); if (focusStatus && focusStatus->num == 12) { /* * We get a 4x3 grid of regions by default. Calculate the average * FoM over the central two positions to give an overall scene FoM. * This can change later if it is not deemed suitable. */ - int32_t focusFoM = (focusStatus->focus_measures[5] + focusStatus->focus_measures[6]) / 2; + int32_t focusFoM = (focusStatus->focusMeasures[5] + focusStatus->focusMeasures[6]) / 2; libcameraMetadata_.set(controls::FocusFoM, focusFoM); } - CcmStatus *ccmStatus = rpiMetadata_.GetLocked("ccm.status"); + CcmStatus *ccmStatus = rpiMetadata_.getLocked("ccm.status"); if (ccmStatus) { float m[9]; for (unsigned int i = 0; i < 9; i++) @@ -695,7 +695,7 @@ void IPARPi::queueRequest(const ControlList &controls) switch (ctrl.first) { case controls::AE_ENABLE: { - RPiController::Algorithm *agc = controller_.GetAlgorithm("agc"); + RPiController::Algorithm *agc = controller_.getAlgorithm("agc"); if (!agc) { LOG(IPARPI, Warning) << "Could not set AE_ENABLE - no AGC algorithm"; @@ -703,9 +703,9 @@ void IPARPi::queueRequest(const ControlList &controls) } if (ctrl.second.get() == false) - agc->Pause(); + agc->pause(); else - agc->Resume(); + agc->resume(); libcameraMetadata_.set(controls::AeEnable, ctrl.second.get()); break; @@ -713,7 +713,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::EXPOSURE_TIME: { RPiController::AgcAlgorithm *agc = dynamic_cast( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (!agc) { LOG(IPARPI, Warning) << "Could not set EXPOSURE_TIME - no AGC algorithm"; @@ -721,7 +721,7 @@ void IPARPi::queueRequest(const ControlList &controls) } /* The control provides units of microseconds. */ - agc->SetFixedShutter(ctrl.second.get() * 1.0us); + agc->setFixedShutter(ctrl.second.get() * 1.0us); libcameraMetadata_.set(controls::ExposureTime, ctrl.second.get()); break; @@ -729,14 +729,14 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::ANALOGUE_GAIN: { RPiController::AgcAlgorithm *agc = dynamic_cast( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (!agc) { LOG(IPARPI, Warning) << "Could not set ANALOGUE_GAIN - no AGC algorithm"; break; } - agc->SetFixedAnalogueGain(ctrl.second.get()); + agc->setFixedAnalogueGain(ctrl.second.get()); libcameraMetadata_.set(controls::AnalogueGain, ctrl.second.get()); @@ -745,7 +745,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AE_METERING_MODE: { RPiController::AgcAlgorithm *agc = dynamic_cast( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (!agc) { LOG(IPARPI, Warning) << "Could not set AE_METERING_MODE - no AGC algorithm"; @@ -754,7 +754,7 @@ void IPARPi::queueRequest(const ControlList &controls) int32_t idx = ctrl.second.get(); if (MeteringModeTable.count(idx)) { - agc->SetMeteringMode(MeteringModeTable.at(idx)); + agc->setMeteringMode(MeteringModeTable.at(idx)); libcameraMetadata_.set(controls::AeMeteringMode, idx); } else { LOG(IPARPI, Error) << "Metering mode " << idx @@ -765,7 +765,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AE_CONSTRAINT_MODE: { RPiController::AgcAlgorithm *agc = dynamic_cast( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (!agc) { LOG(IPARPI, Warning) << "Could not set AE_CONSTRAINT_MODE - no AGC algorithm"; @@ -774,7 +774,7 @@ void IPARPi::queueRequest(const ControlList &controls) int32_t idx = ctrl.second.get(); if (ConstraintModeTable.count(idx)) { - agc->SetConstraintMode(ConstraintModeTable.at(idx)); + agc->setConstraintMode(ConstraintModeTable.at(idx)); libcameraMetadata_.set(controls::AeConstraintMode, idx); } else { LOG(IPARPI, Error) << "Constraint mode " << idx @@ -785,7 +785,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AE_EXPOSURE_MODE: { RPiController::AgcAlgorithm *agc = dynamic_cast( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (!agc) { LOG(IPARPI, Warning) << "Could not set AE_EXPOSURE_MODE - no AGC algorithm"; @@ -794,7 +794,7 @@ void IPARPi::queueRequest(const ControlList &controls) int32_t idx = ctrl.second.get(); if (ExposureModeTable.count(idx)) { - agc->SetExposureMode(ExposureModeTable.at(idx)); + agc->setExposureMode(ExposureModeTable.at(idx)); libcameraMetadata_.set(controls::AeExposureMode, idx); } else { LOG(IPARPI, Error) << "Exposure mode " << idx @@ -805,7 +805,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::EXPOSURE_VALUE: { RPiController::AgcAlgorithm *agc = dynamic_cast( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (!agc) { LOG(IPARPI, Warning) << "Could not set EXPOSURE_VALUE - no AGC algorithm"; @@ -817,14 +817,14 @@ void IPARPi::queueRequest(const ControlList &controls) * So convert to 2^EV */ double ev = pow(2.0, ctrl.second.get()); - agc->SetEv(ev); + agc->setEv(ev); libcameraMetadata_.set(controls::ExposureValue, ctrl.second.get()); break; } case controls::AWB_ENABLE: { - RPiController::Algorithm *awb = controller_.GetAlgorithm("awb"); + RPiController::Algorithm *awb = controller_.getAlgorithm("awb"); if (!awb) { LOG(IPARPI, Warning) << "Could not set AWB_ENABLE - no AWB algorithm"; @@ -832,9 +832,9 @@ void IPARPi::queueRequest(const ControlList &controls) } if (ctrl.second.get() == false) - awb->Pause(); + awb->pause(); else - awb->Resume(); + awb->resume(); libcameraMetadata_.set(controls::AwbEnable, ctrl.second.get()); @@ -843,7 +843,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AWB_MODE: { RPiController::AwbAlgorithm *awb = dynamic_cast( - controller_.GetAlgorithm("awb")); + controller_.getAlgorithm("awb")); if (!awb) { LOG(IPARPI, Warning) << "Could not set AWB_MODE - no AWB algorithm"; @@ -852,7 +852,7 @@ void IPARPi::queueRequest(const ControlList &controls) int32_t idx = ctrl.second.get(); if (AwbModeTable.count(idx)) { - awb->SetMode(AwbModeTable.at(idx)); + awb->setMode(AwbModeTable.at(idx)); libcameraMetadata_.set(controls::AwbMode, idx); } else { LOG(IPARPI, Error) << "AWB mode " << idx @@ -864,14 +864,14 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::COLOUR_GAINS: { auto gains = ctrl.second.get>(); RPiController::AwbAlgorithm *awb = dynamic_cast( - controller_.GetAlgorithm("awb")); + controller_.getAlgorithm("awb")); if (!awb) { LOG(IPARPI, Warning) << "Could not set COLOUR_GAINS - no AWB algorithm"; break; } - awb->SetManualGains(gains[0], gains[1]); + awb->setManualGains(gains[0], gains[1]); if (gains[0] != 0.0f && gains[1] != 0.0f) /* A gain of 0.0f will switch back to auto mode. */ libcameraMetadata_.set(controls::ColourGains, @@ -881,14 +881,14 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::BRIGHTNESS: { RPiController::ContrastAlgorithm *contrast = dynamic_cast( - controller_.GetAlgorithm("contrast")); + controller_.getAlgorithm("contrast")); if (!contrast) { LOG(IPARPI, Warning) << "Could not set BRIGHTNESS - no contrast algorithm"; break; } - contrast->SetBrightness(ctrl.second.get() * 65536); + contrast->setBrightness(ctrl.second.get() * 65536); libcameraMetadata_.set(controls::Brightness, ctrl.second.get()); break; @@ -896,14 +896,14 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::CONTRAST: { RPiController::ContrastAlgorithm *contrast = dynamic_cast( - controller_.GetAlgorithm("contrast")); + controller_.getAlgorithm("contrast")); if (!contrast) { LOG(IPARPI, Warning) << "Could not set CONTRAST - no contrast algorithm"; break; } - contrast->SetContrast(ctrl.second.get()); + contrast->setContrast(ctrl.second.get()); libcameraMetadata_.set(controls::Contrast, ctrl.second.get()); break; @@ -911,14 +911,14 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::SATURATION: { RPiController::CcmAlgorithm *ccm = dynamic_cast( - controller_.GetAlgorithm("ccm")); + controller_.getAlgorithm("ccm")); if (!ccm) { LOG(IPARPI, Warning) << "Could not set SATURATION - no ccm algorithm"; break; } - ccm->SetSaturation(ctrl.second.get()); + ccm->setSaturation(ctrl.second.get()); libcameraMetadata_.set(controls::Saturation, ctrl.second.get()); break; @@ -926,14 +926,14 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::SHARPNESS: { RPiController::SharpenAlgorithm *sharpen = dynamic_cast( - controller_.GetAlgorithm("sharpen")); + controller_.getAlgorithm("sharpen")); if (!sharpen) { LOG(IPARPI, Warning) << "Could not set SHARPNESS - no sharpen algorithm"; break; } - sharpen->SetStrength(ctrl.second.get()); + sharpen->setStrength(ctrl.second.get()); libcameraMetadata_.set(controls::Sharpness, ctrl.second.get()); break; @@ -952,7 +952,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::NOISE_REDUCTION_MODE: { RPiController::DenoiseAlgorithm *sdn = dynamic_cast( - controller_.GetAlgorithm("SDN")); + controller_.getAlgorithm("SDN")); if (!sdn) { LOG(IPARPI, Warning) << "Could not set NOISE_REDUCTION_MODE - no SDN algorithm"; @@ -962,7 +962,7 @@ void IPARPi::queueRequest(const ControlList &controls) int32_t idx = ctrl.second.get(); auto mode = DenoiseModeTable.find(idx); if (mode != DenoiseModeTable.end()) { - sdn->SetMode(mode->second); + sdn->setMode(mode->second); /* * \todo If the colour denoise is not going to run due to an @@ -1014,7 +1014,7 @@ void IPARPi::prepareISP(const ISPConfig &data) * This may overwrite the DeviceStatus using values from the sensor * metadata, and may also do additional custom processing. */ - helper_->Prepare(embeddedBuffer, rpiMetadata_); + helper_->prepare(embeddedBuffer, rpiMetadata_); /* Done with embedded data now, return to pipeline handler asap. */ if (data.embeddedBufferPresent) @@ -1030,7 +1030,7 @@ void IPARPi::prepareISP(const ISPConfig &data) * current frame, or any other bits of metadata that were added * in helper_->Prepare(). */ - rpiMetadata_.Merge(lastMetadata); + rpiMetadata_.merge(lastMetadata); processPending_ = false; return; } @@ -1040,48 +1040,48 @@ void IPARPi::prepareISP(const ISPConfig &data) ControlList ctrls(ispCtrls_); - controller_.Prepare(&rpiMetadata_); + controller_.prepare(&rpiMetadata_); /* Lock the metadata buffer to avoid constant locks/unlocks. */ std::unique_lock lock(rpiMetadata_); - AwbStatus *awbStatus = rpiMetadata_.GetLocked("awb.status"); + AwbStatus *awbStatus = rpiMetadata_.getLocked("awb.status"); if (awbStatus) applyAWB(awbStatus, ctrls); - CcmStatus *ccmStatus = rpiMetadata_.GetLocked("ccm.status"); + CcmStatus *ccmStatus = rpiMetadata_.getLocked("ccm.status"); if (ccmStatus) applyCCM(ccmStatus, ctrls); - AgcStatus *dgStatus = rpiMetadata_.GetLocked("agc.status"); + AgcStatus *dgStatus = rpiMetadata_.getLocked("agc.status"); if (dgStatus) applyDG(dgStatus, ctrls); - AlscStatus *lsStatus = rpiMetadata_.GetLocked("alsc.status"); + AlscStatus *lsStatus = rpiMetadata_.getLocked("alsc.status"); if (lsStatus) applyLS(lsStatus, ctrls); - ContrastStatus *contrastStatus = rpiMetadata_.GetLocked("contrast.status"); + ContrastStatus *contrastStatus = rpiMetadata_.getLocked("contrast.status"); if (contrastStatus) applyGamma(contrastStatus, ctrls); - BlackLevelStatus *blackLevelStatus = rpiMetadata_.GetLocked("black_level.status"); + BlackLevelStatus *blackLevelStatus = rpiMetadata_.getLocked("black_level.status"); if (blackLevelStatus) applyBlackLevel(blackLevelStatus, ctrls); - GeqStatus *geqStatus = rpiMetadata_.GetLocked("geq.status"); + GeqStatus *geqStatus = rpiMetadata_.getLocked("geq.status"); if (geqStatus) applyGEQ(geqStatus, ctrls); - DenoiseStatus *denoiseStatus = rpiMetadata_.GetLocked("denoise.status"); + DenoiseStatus *denoiseStatus = rpiMetadata_.getLocked("denoise.status"); if (denoiseStatus) applyDenoise(denoiseStatus, ctrls); - SharpenStatus *sharpenStatus = rpiMetadata_.GetLocked("sharpen.status"); + SharpenStatus *sharpenStatus = rpiMetadata_.getLocked("sharpen.status"); if (sharpenStatus) applySharpen(sharpenStatus, ctrls); - DpcStatus *dpcStatus = rpiMetadata_.GetLocked("dpc.status"); + DpcStatus *dpcStatus = rpiMetadata_.getLocked("dpc.status"); if (dpcStatus) applyDPC(dpcStatus, ctrls); @@ -1097,13 +1097,13 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls) int32_t gainCode = sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get(); int32_t vblank = sensorControls.get(V4L2_CID_VBLANK).get(); - deviceStatus.shutter_speed = helper_->Exposure(exposureLines); - deviceStatus.analogue_gain = helper_->Gain(gainCode); - deviceStatus.frame_length = mode_.height + vblank; + deviceStatus.shutterSpeed = helper_->exposure(exposureLines); + deviceStatus.analogueGain = helper_->gain(gainCode); + deviceStatus.frameLength = mode_.height + vblank; LOG(IPARPI, Debug) << "Metadata - " << deviceStatus; - rpiMetadata_.Set("device.status", deviceStatus); + rpiMetadata_.set("device.status", deviceStatus); } void IPARPi::processStats(unsigned int bufferId) @@ -1117,11 +1117,11 @@ void IPARPi::processStats(unsigned int bufferId) Span mem = it->second.planes()[0]; bcm2835_isp_stats *stats = reinterpret_cast(mem.data()); RPiController::StatisticsPtr statistics = std::make_shared(*stats); - helper_->Process(statistics, rpiMetadata_); - controller_.Process(statistics, &rpiMetadata_); + helper_->process(statistics, rpiMetadata_); + controller_.process(statistics, &rpiMetadata_); struct AgcStatus agcStatus; - if (rpiMetadata_.Get("agc.status", agcStatus) == 0) { + if (rpiMetadata_.get("agc.status", agcStatus) == 0) { ControlList ctrls(sensorCtrls_); applyAGC(&agcStatus, ctrls); @@ -1131,19 +1131,19 @@ void IPARPi::processStats(unsigned int bufferId) void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) { - LOG(IPARPI, Debug) << "Applying WB R: " << awbStatus->gain_r << " B: " - << awbStatus->gain_b; + LOG(IPARPI, Debug) << "Applying WB R: " << awbStatus->gainR << " B: " + << awbStatus->gainB; ctrls.set(V4L2_CID_RED_BALANCE, - static_cast(awbStatus->gain_r * 1000)); + static_cast(awbStatus->gainR * 1000)); ctrls.set(V4L2_CID_BLUE_BALANCE, - static_cast(awbStatus->gain_b * 1000)); + static_cast(awbStatus->gainB * 1000)); } void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDuration) { - const Duration minSensorFrameDuration = mode_.min_frame_length * mode_.line_length; - const Duration maxSensorFrameDuration = mode_.max_frame_length * mode_.line_length; + const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.lineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; /* * This will only be applied once AGC recalculations occur. @@ -1164,20 +1164,20 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur /* * Calculate the maximum exposure time possible for the AGC to use. - * GetVBlanking() will update maxShutter with the largest exposure + * getVBlanking() will update maxShutter with the largest exposure * value possible. */ Duration maxShutter = Duration::max(); - helper_->GetVBlanking(maxShutter, minFrameDuration_, maxFrameDuration_); + helper_->getVBlanking(maxShutter, minFrameDuration_, maxFrameDuration_); RPiController::AgcAlgorithm *agc = dynamic_cast( - controller_.GetAlgorithm("agc")); - agc->SetMaxShutter(maxShutter); + controller_.getAlgorithm("agc")); + agc->setMaxShutter(maxShutter); } void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) { - int32_t gainCode = helper_->GainCode(agcStatus->analogue_gain); + int32_t gainCode = helper_->gainCode(agcStatus->analogueGain); /* * Ensure anything larger than the max gain code will not be passed to @@ -1186,15 +1186,15 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) */ gainCode = std::min(gainCode, maxSensorGainCode_); - /* GetVBlanking might clip exposure time to the fps limits. */ - Duration exposure = agcStatus->shutter_time; - int32_t vblanking = helper_->GetVBlanking(exposure, minFrameDuration_, maxFrameDuration_); - int32_t exposureLines = helper_->ExposureLines(exposure); + /* getVBlanking might clip exposure time to the fps limits. */ + Duration exposure = agcStatus->shutterTime; + int32_t vblanking = helper_->getVBlanking(exposure, minFrameDuration_, maxFrameDuration_); + int32_t exposureLines = helper_->exposureLines(exposure); LOG(IPARPI, Debug) << "Applying AGC Exposure: " << exposure << " (Shutter lines: " << exposureLines << ", AGC requested " - << agcStatus->shutter_time << ") Gain: " - << agcStatus->analogue_gain << " (Gain Code: " + << agcStatus->shutterTime << ") Gain: " + << agcStatus->analogueGain << " (Gain Code: " << gainCode << ")"; /* @@ -1210,7 +1210,7 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) void IPARPi::applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls) { ctrls.set(V4L2_CID_DIGITAL_GAIN, - static_cast(dgStatus->digital_gain * 1000)); + static_cast(dgStatus->digitalGain * 1000)); } void IPARPi::applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls) @@ -1250,9 +1250,9 @@ void IPARPi::applyBlackLevel(const struct BlackLevelStatus *blackLevelStatus, Co bcm2835_isp_black_level blackLevel; blackLevel.enabled = 1; - blackLevel.black_level_r = blackLevelStatus->black_level_r; - blackLevel.black_level_g = blackLevelStatus->black_level_g; - blackLevel.black_level_b = blackLevelStatus->black_level_b; + blackLevel.black_level_r = blackLevelStatus->blackLevelR; + blackLevel.black_level_g = blackLevelStatus->blackLevelG; + blackLevel.black_level_b = blackLevelStatus->blackLevelB; ControlValue c(Span{ reinterpret_cast(&blackLevel), sizeof(blackLevel) }); @@ -1281,8 +1281,8 @@ void IPARPi::applyDenoise(const struct DenoiseStatus *denoiseStatus, ControlList DenoiseMode mode = static_cast(denoiseStatus->mode); denoise.enabled = mode != DenoiseMode::Off; - denoise.constant = denoiseStatus->noise_constant; - denoise.slope.num = 1000 * denoiseStatus->noise_slope; + denoise.constant = denoiseStatus->noiseConstant; + denoise.slope.num = 1000 * denoiseStatus->noiseSlope; denoise.slope.den = 1000; denoise.strength.num = 1000 * denoiseStatus->strength; denoise.strength.den = 1000; From patchwork Tue Jul 26 12:45: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: 16775 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 047CFC3275 for ; Tue, 26 Jul 2022 12:46:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B5CD36331F; Tue, 26 Jul 2022 14:46:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839562; bh=dPOimGnTSzz/eKoPIhQcmpHg0127fFMO6dznMhco1vk=; 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=Bb7QFnLV6m8O3ExYnlWrdMEXloVutPJ9yGG2nHNup5qgaKxwSJr88j/bP+YVyjKLc jawSqjj1JkkLgExsBmit1pE7lErBNAKmxbGOuZEHZ2ACY1spGdXdWpCL3na7gDQBg8 KTE3sI5jxHj3YaKKwmPSOlNykXnxN84v0tAEOU5/9FCCRSPyvVKDoypXbEiv2KTd4l m2hkgXyt+emPyAxKJ/QmYmGe4kziaIrPr3yXoYmlVcxkVsKruANi+6etwYcd3YPUtr 3Pd0X1+uEI38KIe9S9AZADlK8hC4CVs5oh0TcnO0C7pIsp3oW49oe8o7ZiPc8qNMtH hAGIbPgbL/frA== Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D9B0963312 for ; Tue, 26 Jul 2022 14:45:57 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="XsqNyfWw"; dkim-atps=neutral Received: by mail-wr1-x432.google.com with SMTP id v13so12214167wru.12 for ; Tue, 26 Jul 2022 05:45:57 -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=YmyNbZSPij4ypdh0/SHaeqrjh6STaRheTpjix6rLStw=; b=XsqNyfWw29mEmDwnwqt74lxHMf32l88B7YAbD7UaRNJwJwQazTxc4lwWsvx5Aw0wd5 Ge2ykQPW7PpKFLnP9aKho67nsiDwJIsy56FJ2X7ntImZw24ezV2J9bUgJDOrx2lMUYyL 431pQHWJHMwSKs6YUngdE4OPoTwi1Cn38T48eble6bY4VJAhGg0cDQr4usFmqlhqSo6g 4kH6H56+P+b9Xnnl9xb+U2HAu+zNpDHIIWkJlg4Q7nIAof7+OQmIN1RDQ6OGUm0n75+0 MdO3ovvB8z29v8v+15XJnXG/NM1HxPN3IqzUQpOEmSVCzs+D/zgu2AB0p4ZUSGx6TjPh L2/Q== 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=YmyNbZSPij4ypdh0/SHaeqrjh6STaRheTpjix6rLStw=; b=PLJvzkvGVvusB1kfFap7dUXn391Q3zgp+NrXmrf/INE2NzJBvLbAXjgvb5fz6A7A48 08/rRvp2M1zRWa4CqgCQxysN0mZ1HyJdcSyQ5hg+vVYMfIYp2VPVEKfrCGnZtJ4GPxnt IpCx8SlnLkydlR7oR+fGGmwXOA/Qb+X9l3Kfh1D80VcISReg1E+4hfw03pFbAXbNDgR7 RVWjWEo/ZXyRb6hsdsaBVw8XXBV0LraztUZ7dh49jAYY8mLcSPx1ONW0/DJN3mitxaB6 uxaUCLp1XDbKzKw0yUkDhVDLNBkLhqSXRYHfBo4OrZ6TN8YzG7IHCbwyBhcf4FVJ3NoD ru8A== X-Gm-Message-State: AJIora9uF01ZpbRiC0OjJv3BN6tK1Pc0yVZdBUei9ywYs2VhHB6pu7A7 TdXpQD6P0RpUNCqRQUe8F730DfL7JJPSHg== X-Google-Smtp-Source: AGRyM1vVevOMdripn/WRTCFbJmLfISXIeVYD3Z1RA+G+A7EugeF+h3MamavgXm927H+gY0gn5fouEA== X-Received: by 2002:a05:6000:78b:b0:21e:a0fd:ce with SMTP id bu11-20020a056000078b00b0021ea0fd00cemr2076827wrb.309.1658839556468; Tue, 26 Jul 2022 05:45:56 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:45:55 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:34 +0100 Message-Id: <20220726124549.1646-3-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 02/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 src/ipa/raspberrypi/cam_helper* 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/cam_helper.cpp | 88 +++++++++++------------ src/ipa/raspberrypi/cam_helper.hpp | 40 +++++------ src/ipa/raspberrypi/cam_helper_imx219.cpp | 34 ++++----- src/ipa/raspberrypi/cam_helper_imx290.cpp | 32 ++++----- src/ipa/raspberrypi/cam_helper_imx296.cpp | 24 +++---- src/ipa/raspberrypi/cam_helper_imx477.cpp | 72 +++++++++---------- src/ipa/raspberrypi/cam_helper_imx519.cpp | 70 +++++++++--------- src/ipa/raspberrypi/cam_helper_ov5647.cpp | 44 ++++++------ src/ipa/raspberrypi/cam_helper_ov9281.cpp | 28 ++++---- 9 files changed, 216 insertions(+), 216 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index 3f81d4187d4d..45db39506937 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -24,16 +24,16 @@ namespace libcamera { LOG_DECLARE_CATEGORY(IPARPI) } -static std::map cam_helpers; +static std::map camHelpers; -CamHelper *CamHelper::Create(std::string const &cam_name) +CamHelper *CamHelper::create(std::string const &camName) { /* * CamHelpers get registered by static RegisterCamHelper * initialisers. */ - for (auto &p : cam_helpers) { - if (cam_name.find(p.first) != std::string::npos) + for (auto &p : camHelpers) { + if (camName.find(p.first) != std::string::npos) return p.second(); } @@ -50,35 +50,35 @@ CamHelper::~CamHelper() { } -void CamHelper::Prepare(Span buffer, +void CamHelper::prepare(Span buffer, Metadata &metadata) { parseEmbeddedData(buffer, metadata); } -void CamHelper::Process([[maybe_unused]] StatisticsPtr &stats, +void CamHelper::process([[maybe_unused]] StatisticsPtr &stats, [[maybe_unused]] Metadata &metadata) { } -uint32_t CamHelper::ExposureLines(const Duration exposure) const +uint32_t CamHelper::exposureLines(const Duration exposure) const { assert(initialized_); - return exposure / mode_.line_length; + return exposure / mode_.lineLength; } -Duration CamHelper::Exposure(uint32_t exposure_lines) const +Duration CamHelper::exposure(uint32_t exposureLines) const { assert(initialized_); - return exposure_lines * mode_.line_length; + return exposureLines * mode_.lineLength; } -uint32_t CamHelper::GetVBlanking(Duration &exposure, +uint32_t CamHelper::getVBlanking(Duration &exposure, Duration minFrameDuration, Duration maxFrameDuration) const { uint32_t frameLengthMin, frameLengthMax, vblank; - uint32_t exposureLines = ExposureLines(exposure); + uint32_t exposureLines = CamHelper::exposureLines(exposure); assert(initialized_); @@ -86,15 +86,15 @@ uint32_t CamHelper::GetVBlanking(Duration &exposure, * minFrameDuration and maxFrameDuration are clamped by the caller * based on the limits for the active sensor mode. */ - frameLengthMin = minFrameDuration / mode_.line_length; - frameLengthMax = maxFrameDuration / mode_.line_length; + frameLengthMin = minFrameDuration / mode_.lineLength; + frameLengthMax = maxFrameDuration / mode_.lineLength; /* * Limit the exposure to the maximum frame duration requested, and * re-calculate if it has been clipped. */ exposureLines = std::min(frameLengthMax - frameIntegrationDiff_, exposureLines); - exposure = Exposure(exposureLines); + exposure = CamHelper::exposure(exposureLines); /* Limit the vblank to the range allowed by the frame length limits. */ vblank = std::clamp(exposureLines + frameIntegrationDiff_, @@ -102,34 +102,34 @@ uint32_t CamHelper::GetVBlanking(Duration &exposure, return vblank; } -void CamHelper::SetCameraMode(const CameraMode &mode) +void CamHelper::setCameraMode(const CameraMode &mode) { mode_ = mode; if (parser_) { - parser_->SetBitsPerPixel(mode.bitdepth); - parser_->SetLineLengthBytes(0); /* We use SetBufferSize. */ + parser_->setBitsPerPixel(mode.bitdepth); + parser_->setLineLengthBytes(0); /* We use SetBufferSize. */ } initialized_ = true; } -void CamHelper::GetDelays(int &exposure_delay, int &gain_delay, - int &vblank_delay) const +void CamHelper::getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay) const { /* * These values are correct for many sensors. Other sensors will * need to over-ride this function. */ - exposure_delay = 2; - gain_delay = 1; - vblank_delay = 2; + exposureDelay = 2; + gainDelay = 1; + vblankDelay = 2; } -bool CamHelper::SensorEmbeddedDataPresent() const +bool CamHelper::sensorEmbeddedDataPresent() const { return false; } -double CamHelper::GetModeSensitivity([[maybe_unused]] const CameraMode &mode) const +double CamHelper::getModeSensitivity([[maybe_unused]] const CameraMode &mode) const { /* * Most sensors have the same sensitivity in every mode, but this @@ -140,7 +140,7 @@ double CamHelper::GetModeSensitivity([[maybe_unused]] const CameraMode &mode) co return 1.0; } -unsigned int CamHelper::HideFramesStartup() const +unsigned int CamHelper::hideFramesStartup() const { /* * The number of frames when a camera first starts that shouldn't be @@ -149,19 +149,19 @@ unsigned int CamHelper::HideFramesStartup() const return 0; } -unsigned int CamHelper::HideFramesModeSwitch() const +unsigned int CamHelper::hideFramesModeSwitch() const { /* After a mode switch, many sensors return valid frames immediately. */ return 0; } -unsigned int CamHelper::MistrustFramesStartup() const +unsigned int CamHelper::mistrustFramesStartup() const { /* Many sensors return a single bad frame on start-up. */ return 1; } -unsigned int CamHelper::MistrustFramesModeSwitch() const +unsigned int CamHelper::mistrustFramesModeSwitch() const { /* Many sensors return valid metadata immediately. */ return 0; @@ -176,13 +176,13 @@ void CamHelper::parseEmbeddedData(Span buffer, if (buffer.empty()) return; - if (parser_->Parse(buffer, registers) != MdParser::Status::OK) { + if (parser_->parse(buffer, registers) != MdParser::Status::OK) { LOG(IPARPI, Error) << "Embedded data buffer parsing failed"; return; } - PopulateMetadata(registers, parsedMetadata); - metadata.Merge(parsedMetadata); + populateMetadata(registers, parsedMetadata); + metadata.merge(parsedMetadata); /* * Overwrite the exposure/gain, frame length and sensor temperature values @@ -190,30 +190,30 @@ void CamHelper::parseEmbeddedData(Span buffer, * Fetch it first in case any other fields were set meaningfully. */ DeviceStatus deviceStatus, parsedDeviceStatus; - if (metadata.Get("device.status", deviceStatus) || - parsedMetadata.Get("device.status", parsedDeviceStatus)) { + if (metadata.get("device.status", deviceStatus) || + parsedMetadata.get("device.status", parsedDeviceStatus)) { LOG(IPARPI, Error) << "DeviceStatus not found"; return; } - deviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed; - deviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain; - deviceStatus.frame_length = parsedDeviceStatus.frame_length; - if (parsedDeviceStatus.sensor_temperature) - deviceStatus.sensor_temperature = parsedDeviceStatus.sensor_temperature; + deviceStatus.shutterSpeed = parsedDeviceStatus.shutterSpeed; + deviceStatus.analogueGain = parsedDeviceStatus.analogueGain; + deviceStatus.frameLength = parsedDeviceStatus.frameLength; + if (parsedDeviceStatus.sensorTemperature) + deviceStatus.sensorTemperature = parsedDeviceStatus.sensorTemperature; LOG(IPARPI, Debug) << "Metadata updated - " << deviceStatus; - metadata.Set("device.status", deviceStatus); + metadata.set("device.status", deviceStatus); } -void CamHelper::PopulateMetadata([[maybe_unused]] const MdParser::RegisterMap ®isters, +void CamHelper::populateMetadata([[maybe_unused]] const MdParser::RegisterMap ®isters, [[maybe_unused]] Metadata &metadata) const { } -RegisterCamHelper::RegisterCamHelper(char const *cam_name, - CamHelperCreateFunc create_func) +RegisterCamHelper::RegisterCamHelper(char const *camName, + CamHelperCreateFunc createFunc) { - cam_helpers[std::string(cam_name)] = create_func; + camHelpers[std::string(camName)] = createFunc; } diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp index 300f8f8a2d3b..0cd718c4bc4e 100644 --- a/src/ipa/raspberrypi/cam_helper.hpp +++ b/src/ipa/raspberrypi/cam_helper.hpp @@ -69,33 +69,33 @@ namespace RPiController { class CamHelper { public: - static CamHelper *Create(std::string const &cam_name); + static CamHelper *create(std::string const &camName); CamHelper(std::unique_ptr parser, unsigned int frameIntegrationDiff); virtual ~CamHelper(); - void SetCameraMode(const CameraMode &mode); - virtual void Prepare(libcamera::Span buffer, + void setCameraMode(const CameraMode &mode); + virtual void prepare(libcamera::Span buffer, Metadata &metadata); - virtual void Process(StatisticsPtr &stats, Metadata &metadata); - virtual uint32_t ExposureLines(libcamera::utils::Duration exposure) const; - virtual libcamera::utils::Duration Exposure(uint32_t exposure_lines) const; - virtual uint32_t GetVBlanking(libcamera::utils::Duration &exposure, + virtual void process(StatisticsPtr &stats, Metadata &metadata); + virtual uint32_t exposureLines(libcamera::utils::Duration exposure) const; + virtual libcamera::utils::Duration exposure(uint32_t exposureLines) const; + virtual uint32_t getVBlanking(libcamera::utils::Duration &exposure, libcamera::utils::Duration minFrameDuration, libcamera::utils::Duration maxFrameDuration) const; - virtual uint32_t GainCode(double gain) const = 0; - virtual double Gain(uint32_t gain_code) const = 0; - virtual void GetDelays(int &exposure_delay, int &gain_delay, - int &vblank_delay) const; - virtual bool SensorEmbeddedDataPresent() const; - virtual double GetModeSensitivity(const CameraMode &mode) const; - virtual unsigned int HideFramesStartup() const; - virtual unsigned int HideFramesModeSwitch() const; - virtual unsigned int MistrustFramesStartup() const; - virtual unsigned int MistrustFramesModeSwitch() const; + virtual uint32_t gainCode(double gain) const = 0; + virtual double gain(uint32_t gainCode) const = 0; + virtual void getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay) const; + virtual bool sensorEmbeddedDataPresent() const; + virtual double getModeSensitivity(const CameraMode &mode) const; + virtual unsigned int hideFramesStartup() const; + virtual unsigned int hideFramesModeSwitch() const; + virtual unsigned int mistrustFramesStartup() const; + virtual unsigned int mistrustFramesModeSwitch() const; protected: void parseEmbeddedData(libcamera::Span buffer, Metadata &metadata); - virtual void PopulateMetadata(const MdParser::RegisterMap ®isters, + virtual void populateMetadata(const MdParser::RegisterMap ®isters, Metadata &metadata) const; std::unique_ptr parser_; @@ -116,8 +116,8 @@ private: typedef CamHelper *(*CamHelperCreateFunc)(); struct RegisterCamHelper { - RegisterCamHelper(char const *cam_name, - CamHelperCreateFunc create_func); + RegisterCamHelper(char const *camName, + CamHelperCreateFunc createFunc); }; } // namespace RPi diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp index a3caab714602..17c35143923a 100644 --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp @@ -39,10 +39,10 @@ class CamHelperImx219 : public CamHelper { public: CamHelperImx219(); - uint32_t GainCode(double gain) const override; - double Gain(uint32_t gain_code) const override; - unsigned int MistrustFramesModeSwitch() const override; - bool SensorEmbeddedDataPresent() const override; + uint32_t gainCode(double gain) const override; + double gain(uint32_t gainCode) const override; + unsigned int mistrustFramesModeSwitch() const override; + bool sensorEmbeddedDataPresent() const override; private: /* @@ -51,7 +51,7 @@ private: */ static constexpr int frameIntegrationDiff = 4; - void PopulateMetadata(const MdParser::RegisterMap ®isters, + void populateMetadata(const MdParser::RegisterMap ®isters, Metadata &metadata) const override; }; @@ -64,17 +64,17 @@ CamHelperImx219::CamHelperImx219() { } -uint32_t CamHelperImx219::GainCode(double gain) const +uint32_t CamHelperImx219::gainCode(double gain) const { return (uint32_t)(256 - 256 / gain); } -double CamHelperImx219::Gain(uint32_t gain_code) const +double CamHelperImx219::gain(uint32_t gainCode) const { - return 256.0 / (256 - gain_code); + return 256.0 / (256 - gainCode); } -unsigned int CamHelperImx219::MistrustFramesModeSwitch() const +unsigned int CamHelperImx219::mistrustFramesModeSwitch() const { /* * For reasons unknown, we do occasionally get a bogus metadata frame @@ -84,26 +84,26 @@ unsigned int CamHelperImx219::MistrustFramesModeSwitch() const return 1; } -bool CamHelperImx219::SensorEmbeddedDataPresent() const +bool CamHelperImx219::sensorEmbeddedDataPresent() const { return ENABLE_EMBEDDED_DATA; } -void CamHelperImx219::PopulateMetadata(const MdParser::RegisterMap ®isters, +void CamHelperImx219::populateMetadata(const MdParser::RegisterMap ®isters, Metadata &metadata) const { DeviceStatus deviceStatus; - deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); - deviceStatus.analogue_gain = Gain(registers.at(gainReg)); - deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); + deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); + deviceStatus.analogueGain = gain(registers.at(gainReg)); + deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); - metadata.Set("device.status", deviceStatus); + metadata.set("device.status", deviceStatus); } -static CamHelper *Create() +static CamHelper *create() { return new CamHelperImx219(); } -static RegisterCamHelper reg("imx219", &Create); +static RegisterCamHelper reg("imx219", &create); diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp index 871c1f8eaec4..0d9a94d8d3f6 100644 --- a/src/ipa/raspberrypi/cam_helper_imx290.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp @@ -15,11 +15,11 @@ class CamHelperImx290 : public CamHelper { public: CamHelperImx290(); - uint32_t GainCode(double gain) const override; - double Gain(uint32_t gain_code) const override; - void GetDelays(int &exposure_delay, int &gain_delay, - int &vblank_delay) const override; - unsigned int HideFramesModeSwitch() const override; + uint32_t gainCode(double gain) const override; + double gain(uint32_t gainCode) const override; + void getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay) const override; + unsigned int hideFramesModeSwitch() const override; private: /* @@ -34,34 +34,34 @@ CamHelperImx290::CamHelperImx290() { } -uint32_t CamHelperImx290::GainCode(double gain) const +uint32_t CamHelperImx290::gainCode(double gain) const { int code = 66.6667 * log10(gain); return std::max(0, std::min(code, 0xf0)); } -double CamHelperImx290::Gain(uint32_t gain_code) const +double CamHelperImx290::gain(uint32_t gainCode) const { - return pow(10, 0.015 * gain_code); + return pow(10, 0.015 * gainCode); } -void CamHelperImx290::GetDelays(int &exposure_delay, int &gain_delay, - int &vblank_delay) const +void CamHelperImx290::getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay) const { - exposure_delay = 2; - gain_delay = 2; - vblank_delay = 2; + exposureDelay = 2; + gainDelay = 2; + vblankDelay = 2; } -unsigned int CamHelperImx290::HideFramesModeSwitch() const +unsigned int CamHelperImx290::hideFramesModeSwitch() const { /* After a mode switch, we seem to get 1 bad frame. */ return 1; } -static CamHelper *Create() +static CamHelper *create() { return new CamHelperImx290(); } -static RegisterCamHelper reg("imx290", &Create); +static RegisterCamHelper reg("imx290", &create); diff --git a/src/ipa/raspberrypi/cam_helper_imx296.cpp b/src/ipa/raspberrypi/cam_helper_imx296.cpp index a1a771cb96d5..15674335fa75 100644 --- a/src/ipa/raspberrypi/cam_helper_imx296.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx296.cpp @@ -19,10 +19,10 @@ class CamHelperImx296 : public CamHelper { public: CamHelperImx296(); - uint32_t GainCode(double gain) const override; - double Gain(uint32_t gain_code) const override; - uint32_t ExposureLines(Duration exposure) const override; - Duration Exposure(uint32_t exposure_lines) const override; + uint32_t gainCode(double gain) const override; + double gain(uint32_t gainCode) const override; + uint32_t exposureLines(Duration exposure) const override; + Duration exposure(uint32_t exposureLines) const override; private: static constexpr uint32_t maxGainCode = 239; @@ -40,30 +40,30 @@ CamHelperImx296::CamHelperImx296() { } -uint32_t CamHelperImx296::GainCode(double gain) const +uint32_t CamHelperImx296::gainCode(double gain) const { uint32_t code = 20 * std::log10(gain) * 10; return std::min(code, maxGainCode); } -double CamHelperImx296::Gain(uint32_t gain_code) const +double CamHelperImx296::gain(uint32_t gainCode) const { - return std::pow(10.0, gain_code / 200.0); + return std::pow(10.0, gainCode / 200.0); } -uint32_t CamHelperImx296::ExposureLines(Duration exposure) const +uint32_t CamHelperImx296::exposureLines(Duration exposure) const { return (exposure - 14.26us) / timePerLine; } -Duration CamHelperImx296::Exposure(uint32_t exposure_lines) const +Duration CamHelperImx296::exposure(uint32_t exposureLines) const { - return exposure_lines * timePerLine + 14.26us; + return exposureLines * timePerLine + 14.26us; } -static CamHelper *Create() +static CamHelper *create() { return new CamHelperImx296(); } -static RegisterCamHelper reg("imx296", &Create); +static RegisterCamHelper reg("imx296", &create); diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 0e1c0dbd142f..0767a5e1dcc5 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -43,14 +43,14 @@ class CamHelperImx477 : public CamHelper { public: CamHelperImx477(); - uint32_t GainCode(double gain) const override; - double Gain(uint32_t gain_code) const override; - void Prepare(libcamera::Span buffer, Metadata &metadata) override; - uint32_t GetVBlanking(Duration &exposure, Duration minFrameDuration, + uint32_t gainCode(double gain) const override; + double gain(uint32_t gainCode) const override; + void prepare(libcamera::Span buffer, Metadata &metadata) override; + uint32_t getVBlanking(Duration &exposure, Duration minFrameDuration, Duration maxFrameDuration) const override; - void GetDelays(int &exposure_delay, int &gain_delay, - int &vblank_delay) const override; - bool SensorEmbeddedDataPresent() const override; + void getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay) const override; + bool sensorEmbeddedDataPresent() const override; private: /* @@ -63,7 +63,7 @@ private: /* Largest long exposure scale factor given as a left shift on the frame length. */ static constexpr int longExposureShiftMax = 7; - void PopulateMetadata(const MdParser::RegisterMap ®isters, + void populateMetadata(const MdParser::RegisterMap ®isters, Metadata &metadata) const override; }; @@ -72,22 +72,22 @@ CamHelperImx477::CamHelperImx477() { } -uint32_t CamHelperImx477::GainCode(double gain) const +uint32_t CamHelperImx477::gainCode(double gain) const { return static_cast(1024 - 1024 / gain); } -double CamHelperImx477::Gain(uint32_t gain_code) const +double CamHelperImx477::gain(uint32_t gainCode) const { - return 1024.0 / (1024 - gain_code); + return 1024.0 / (1024 - gainCode); } -void CamHelperImx477::Prepare(libcamera::Span buffer, Metadata &metadata) +void CamHelperImx477::prepare(libcamera::Span buffer, Metadata &metadata) { MdParser::RegisterMap registers; DeviceStatus deviceStatus; - if (metadata.Get("device.status", deviceStatus)) { + if (metadata.get("device.status", deviceStatus)) { LOG(IPARPI, Error) << "DeviceStatus not found from DelayedControls"; return; } @@ -105,27 +105,27 @@ void CamHelperImx477::Prepare(libcamera::Span buffer, Metadata &m * Otherwise, all values are updated with what is reported in the * embedded data. */ - if (deviceStatus.frame_length > frameLengthMax) { + if (deviceStatus.frameLength > frameLengthMax) { DeviceStatus parsedDeviceStatus; - metadata.Get("device.status", parsedDeviceStatus); - parsedDeviceStatus.shutter_speed = deviceStatus.shutter_speed; - parsedDeviceStatus.frame_length = deviceStatus.frame_length; - metadata.Set("device.status", parsedDeviceStatus); + metadata.get("device.status", parsedDeviceStatus); + parsedDeviceStatus.shutterSpeed = deviceStatus.shutterSpeed; + parsedDeviceStatus.frameLength = deviceStatus.frameLength; + metadata.set("device.status", parsedDeviceStatus); LOG(IPARPI, Debug) << "Metadata updated for long exposure: " << parsedDeviceStatus; } } -uint32_t CamHelperImx477::GetVBlanking(Duration &exposure, +uint32_t CamHelperImx477::getVBlanking(Duration &exposure, Duration minFrameDuration, Duration maxFrameDuration) const { uint32_t frameLength, exposureLines; unsigned int shift = 0; - frameLength = mode_.height + CamHelper::GetVBlanking(exposure, minFrameDuration, + frameLength = mode_.height + CamHelper::getVBlanking(exposure, minFrameDuration, maxFrameDuration); /* * Check if the frame length calculated needs to be setup for long @@ -144,43 +144,43 @@ uint32_t CamHelperImx477::GetVBlanking(Duration &exposure, if (shift) { /* Account for any rounding in the scaled frame length value. */ frameLength <<= shift; - exposureLines = ExposureLines(exposure); + exposureLines = CamHelperImx477::exposureLines(exposure); exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff); - exposure = Exposure(exposureLines); + exposure = CamHelperImx477::exposure(exposureLines); } return frameLength - mode_.height; } -void CamHelperImx477::GetDelays(int &exposure_delay, int &gain_delay, - int &vblank_delay) const +void CamHelperImx477::getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay) const { - exposure_delay = 2; - gain_delay = 2; - vblank_delay = 3; + exposureDelay = 2; + gainDelay = 2; + vblankDelay = 3; } -bool CamHelperImx477::SensorEmbeddedDataPresent() const +bool CamHelperImx477::sensorEmbeddedDataPresent() const { return true; } -void CamHelperImx477::PopulateMetadata(const MdParser::RegisterMap ®isters, +void CamHelperImx477::populateMetadata(const MdParser::RegisterMap ®isters, Metadata &metadata) const { DeviceStatus deviceStatus; - deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); - deviceStatus.analogue_gain = Gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); - deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); - deviceStatus.sensor_temperature = std::clamp(registers.at(temperatureReg), -20, 80); + deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); + deviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); + deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); + deviceStatus.sensorTemperature = std::clamp(registers.at(temperatureReg), -20, 80); - metadata.Set("device.status", deviceStatus); + metadata.set("device.status", deviceStatus); } -static CamHelper *Create() +static CamHelper *create() { return new CamHelperImx477(); } -static RegisterCamHelper reg("imx477", &Create); +static RegisterCamHelper reg("imx477", &create); diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp index eaf24982b37f..1752760e64a2 100644 --- a/src/ipa/raspberrypi/cam_helper_imx519.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp @@ -43,14 +43,14 @@ class CamHelperImx519 : public CamHelper { public: CamHelperImx519(); - uint32_t GainCode(double gain) const override; - double Gain(uint32_t gain_code) const override; - void Prepare(libcamera::Span buffer, Metadata &metadata) override; - uint32_t GetVBlanking(Duration &exposure, Duration minFrameDuration, + uint32_t gainCode(double gain) const override; + double gain(uint32_t gainCode) const override; + void prepare(libcamera::Span buffer, Metadata &metadata) override; + uint32_t getVBlanking(Duration &exposure, Duration minFrameDuration, Duration maxFrameDuration) const override; - void GetDelays(int &exposure_delay, int &gain_delay, - int &vblank_delay) const override; - bool SensorEmbeddedDataPresent() const override; + void getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay) const override; + bool sensorEmbeddedDataPresent() const override; private: /* @@ -63,7 +63,7 @@ private: /* Largest long exposure scale factor given as a left shift on the frame length. */ static constexpr int longExposureShiftMax = 7; - void PopulateMetadata(const MdParser::RegisterMap ®isters, + void populateMetadata(const MdParser::RegisterMap ®isters, Metadata &metadata) const override; }; @@ -72,22 +72,22 @@ CamHelperImx519::CamHelperImx519() { } -uint32_t CamHelperImx519::GainCode(double gain) const +uint32_t CamHelperImx519::gainCode(double gain) const { return static_cast(1024 - 1024 / gain); } -double CamHelperImx519::Gain(uint32_t gain_code) const +double CamHelperImx519::gain(uint32_t gainCode) const { - return 1024.0 / (1024 - gain_code); + return 1024.0 / (1024 - gainCode); } -void CamHelperImx519::Prepare(libcamera::Span buffer, Metadata &metadata) +void CamHelperImx519::prepare(libcamera::Span buffer, Metadata &metadata) { MdParser::RegisterMap registers; DeviceStatus deviceStatus; - if (metadata.Get("device.status", deviceStatus)) { + if (metadata.get("device.status", deviceStatus)) { LOG(IPARPI, Error) << "DeviceStatus not found from DelayedControls"; return; } @@ -105,27 +105,27 @@ void CamHelperImx519::Prepare(libcamera::Span buffer, Metadata &m * Otherwise, all values are updated with what is reported in the * embedded data. */ - if (deviceStatus.frame_length > frameLengthMax) { + if (deviceStatus.frameLength > frameLengthMax) { DeviceStatus parsedDeviceStatus; - metadata.Get("device.status", parsedDeviceStatus); - parsedDeviceStatus.shutter_speed = deviceStatus.shutter_speed; - parsedDeviceStatus.frame_length = deviceStatus.frame_length; - metadata.Set("device.status", parsedDeviceStatus); + metadata.get("device.status", parsedDeviceStatus); + parsedDeviceStatus.shutterSpeed = deviceStatus.shutterSpeed; + parsedDeviceStatus.frameLength = deviceStatus.frameLength; + metadata.set("device.status", parsedDeviceStatus); LOG(IPARPI, Debug) << "Metadata updated for long exposure: " << parsedDeviceStatus; } } -uint32_t CamHelperImx519::GetVBlanking(Duration &exposure, +uint32_t CamHelperImx519::getVBlanking(Duration &exposure, Duration minFrameDuration, Duration maxFrameDuration) const { uint32_t frameLength, exposureLines; unsigned int shift = 0; - frameLength = mode_.height + CamHelper::GetVBlanking(exposure, minFrameDuration, + frameLength = mode_.height + CamHelper::getVBlanking(exposure, minFrameDuration, maxFrameDuration); /* * Check if the frame length calculated needs to be setup for long @@ -144,42 +144,42 @@ uint32_t CamHelperImx519::GetVBlanking(Duration &exposure, if (shift) { /* Account for any rounding in the scaled frame length value. */ frameLength <<= shift; - exposureLines = ExposureLines(exposure); + exposureLines = CamHelperImx519::exposureLines(exposure); exposureLines = std::min(exposureLines, frameLength - frameIntegrationDiff); - exposure = Exposure(exposureLines); + exposure = CamHelperImx519::exposure(exposureLines); } return frameLength - mode_.height; } -void CamHelperImx519::GetDelays(int &exposure_delay, int &gain_delay, - int &vblank_delay) const +void CamHelperImx519::getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay) const { - exposure_delay = 2; - gain_delay = 2; - vblank_delay = 3; + exposureDelay = 2; + gainDelay = 2; + vblankDelay = 3; } -bool CamHelperImx519::SensorEmbeddedDataPresent() const +bool CamHelperImx519::sensorEmbeddedDataPresent() const { return true; } -void CamHelperImx519::PopulateMetadata(const MdParser::RegisterMap ®isters, +void CamHelperImx519::populateMetadata(const MdParser::RegisterMap ®isters, Metadata &metadata) const { DeviceStatus deviceStatus; - deviceStatus.shutter_speed = Exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); - deviceStatus.analogue_gain = Gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); - deviceStatus.frame_length = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); + deviceStatus.shutterSpeed = exposure(registers.at(expHiReg) * 256 + registers.at(expLoReg)); + deviceStatus.analogueGain = gain(registers.at(gainHiReg) * 256 + registers.at(gainLoReg)); + deviceStatus.frameLength = registers.at(frameLengthHiReg) * 256 + registers.at(frameLengthLoReg); - metadata.Set("device.status", deviceStatus); + metadata.set("device.status", deviceStatus); } -static CamHelper *Create() +static CamHelper *create() { return new CamHelperImx519(); } -static RegisterCamHelper reg("imx519", &Create); +static RegisterCamHelper reg("imx519", &create); diff --git a/src/ipa/raspberrypi/cam_helper_ov5647.cpp b/src/ipa/raspberrypi/cam_helper_ov5647.cpp index 702c2d07f73a..9dc3fc44e5e8 100644 --- a/src/ipa/raspberrypi/cam_helper_ov5647.cpp +++ b/src/ipa/raspberrypi/cam_helper_ov5647.cpp @@ -15,14 +15,14 @@ class CamHelperOv5647 : public CamHelper { public: CamHelperOv5647(); - uint32_t GainCode(double gain) const override; - double Gain(uint32_t gain_code) const override; - void GetDelays(int &exposure_delay, int &gain_delay, - int &vblank_delay) const override; - unsigned int HideFramesStartup() const override; - unsigned int HideFramesModeSwitch() const override; - unsigned int MistrustFramesStartup() const override; - unsigned int MistrustFramesModeSwitch() const override; + uint32_t gainCode(double gain) const override; + double gain(uint32_t gainCode) const override; + void getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay) const override; + unsigned int hideFramesStartup() const override; + unsigned int hideFramesModeSwitch() const override; + unsigned int mistrustFramesStartup() const override; + unsigned int mistrustFramesModeSwitch() const override; private: /* @@ -42,29 +42,29 @@ CamHelperOv5647::CamHelperOv5647() { } -uint32_t CamHelperOv5647::GainCode(double gain) const +uint32_t CamHelperOv5647::gainCode(double gain) const { return static_cast(gain * 16.0); } -double CamHelperOv5647::Gain(uint32_t gain_code) const +double CamHelperOv5647::gain(uint32_t gainCode) const { - return static_cast(gain_code) / 16.0; + return static_cast(gainCode) / 16.0; } -void CamHelperOv5647::GetDelays(int &exposure_delay, int &gain_delay, - int &vblank_delay) const +void CamHelperOv5647::getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay) const { /* * We run this sensor in a mode where the gain delay is bumped up to * 2. It seems to be the only way to make the delays "predictable". */ - exposure_delay = 2; - gain_delay = 2; - vblank_delay = 2; + exposureDelay = 2; + gainDelay = 2; + vblankDelay = 2; } -unsigned int CamHelperOv5647::HideFramesStartup() const +unsigned int CamHelperOv5647::hideFramesStartup() const { /* * On startup, we get a couple of under-exposed frames which @@ -73,7 +73,7 @@ unsigned int CamHelperOv5647::HideFramesStartup() const return 2; } -unsigned int CamHelperOv5647::HideFramesModeSwitch() const +unsigned int CamHelperOv5647::hideFramesModeSwitch() const { /* * After a mode switch, we get a couple of under-exposed frames which @@ -82,7 +82,7 @@ unsigned int CamHelperOv5647::HideFramesModeSwitch() const return 2; } -unsigned int CamHelperOv5647::MistrustFramesStartup() const +unsigned int CamHelperOv5647::mistrustFramesStartup() const { /* * First couple of frames are under-exposed and are no good for control @@ -91,7 +91,7 @@ unsigned int CamHelperOv5647::MistrustFramesStartup() const return 2; } -unsigned int CamHelperOv5647::MistrustFramesModeSwitch() const +unsigned int CamHelperOv5647::mistrustFramesModeSwitch() const { /* * First couple of frames are under-exposed even after a simple @@ -100,9 +100,9 @@ unsigned int CamHelperOv5647::MistrustFramesModeSwitch() const return 2; } -static CamHelper *Create() +static CamHelper *create() { return new CamHelperOv5647(); } -static RegisterCamHelper reg("ov5647", &Create); +static RegisterCamHelper reg("ov5647", &create); diff --git a/src/ipa/raspberrypi/cam_helper_ov9281.cpp b/src/ipa/raspberrypi/cam_helper_ov9281.cpp index 9de868c31dc0..130450afefc7 100644 --- a/src/ipa/raspberrypi/cam_helper_ov9281.cpp +++ b/src/ipa/raspberrypi/cam_helper_ov9281.cpp @@ -15,10 +15,10 @@ class CamHelperOv9281 : public CamHelper { public: CamHelperOv9281(); - uint32_t GainCode(double gain) const override; - double Gain(uint32_t gain_code) const override; - void GetDelays(int &exposure_delay, int &gain_delay, - int &vblank_delay) const override; + uint32_t gainCode(double gain) const override; + double gain(uint32_t gainCode) const override; + void getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay) const override; private: /* @@ -38,28 +38,28 @@ CamHelperOv9281::CamHelperOv9281() { } -uint32_t CamHelperOv9281::GainCode(double gain) const +uint32_t CamHelperOv9281::gainCode(double gain) const { return static_cast(gain * 16.0); } -double CamHelperOv9281::Gain(uint32_t gain_code) const +double CamHelperOv9281::gain(uint32_t gainCode) const { - return static_cast(gain_code) / 16.0; + return static_cast(gainCode) / 16.0; } -void CamHelperOv9281::GetDelays(int &exposure_delay, int &gain_delay, - int &vblank_delay) const +void CamHelperOv9281::getDelays(int &exposureDelay, int &gainDelay, + int &vblankDelay) const { /* The driver appears to behave as follows: */ - exposure_delay = 2; - gain_delay = 2; - vblank_delay = 2; + exposureDelay = 2; + gainDelay = 2; + vblankDelay = 2; } -static CamHelper *Create() +static CamHelper *create() { return new CamHelperOv9281(); } -static RegisterCamHelper reg("ov9281", &Create); +static RegisterCamHelper reg("ov9281", &create); From patchwork Tue Jul 26 12:45:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16776 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 C870FC3275 for ; Tue, 26 Jul 2022 12:46:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 69BE86331B; Tue, 26 Jul 2022 14:46:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839563; bh=A9qFVsr4ysD6H31zQ+LpZvDY/RnDf/oQQaUK0g3K3kE=; 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=WyERdKHrHdIoN4KgGq2JggLVN+5fGLK6I8hYxDsUV3opcJ6cqvaMKNQZBrkeM8t4e 9FTlJgTkJGERXaUqvix49vSI0w68qFUFODUiMUgfAi1TYWs2ycxibpJnHuUx8gEhf9 dA9YZWhwgFpBUPZiRMmvY8k0JXyvp1cy9S6rjOotHOiKE+g25Q6tTxQrKlliJJEt7l lB41acn142nNjljm3jwn7a9WwkzoxdLlev5uju6U6mNNv6YgAbah0jOhd5qvNSTz/7 wJhUWzcpkZMTTbJYv0KcNn7uqUhvHDX5q2JdWTmdqODr1eEd8dEM+wk64DsC6F64ct 29iz7MthAPkAw== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 72C0560487 for ; Tue, 26 Jul 2022 14:45:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="PsOHaaYv"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id d8so19897595wrp.6 for ; Tue, 26 Jul 2022 05:45:58 -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=C3mG9N/O4kjLV5Q756klG3p/Rxqeg7NfD57FGce0BGs=; b=PsOHaaYvPctkAir9sNFtTN7thp2xGVQ6EM+YUnwFtsSLUCSxk+vlWLPz9ox54FpGXw a4q/MvcgUHsycPbOgFgV+W2vJhoDQ/tIINttIamPdAK5czGAwSxFSOawhxKyYP6uy8WS dDavDxdemekGIM53hHEP0Mhg6W9sFUoF+gf4UsWzrm952sbQ9zjZAujYDhb+EhGRAWbr 1FYKyGy4yo55jZ82nmy/nH8dxPXSGQVAoJtgBZ3HOGXA+sxZwXsRrN5H1W8d99be9MEv 9CgKXIFzEkLj9oH7ryLWgH5qMF4UN6t4tjarslQKeeYpULZRWYCXwZJ6kBoisUKsvLlW tIuA== 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=C3mG9N/O4kjLV5Q756klG3p/Rxqeg7NfD57FGce0BGs=; b=fVhAyfGBwohNGKIa0wVfGWD9hk4JVerJZNn7S8t0d9Lb4RlYkPlOUfpLjs5HtbkdLs xXoEFPSI2HCpP2YqE65MR6/OggiHSXBi1pEsEoKTMmzb6zKwN05lbZ6TOT84U/XZENon 91MXSBv/zmne9A3ddykzcDEUYVytBcMHNxy3UWc5gpRuc6EaSoYZiECFnFADYVPfBUNg +NKnxDyggbRBh8FuBgOVSRnR2b7DZ92lrBS3VEW7rdPDjvPODCZTq2WUJ5rtMyYVVL8N mr4Pxwj+C3pPF1qQMyQcY32jLo90s2Vvvt9bh99Z90+gOOk2wOEFg9sKucQ7KTR51vMA uLMQ== X-Gm-Message-State: AJIora+AvjWVmmOxww+XCBkHPxxLIpUIc58mYJlumHOfI8Tn1TTeH4DY TxveSmFStldfWotFowj7bs1PgkXQ9I21kw== X-Google-Smtp-Source: AGRyM1si9HOcuUc5Ad+6hrUwxsb9YBEHgLt98sAV4nSuNtflCTTzakzc7Qcvq+5fQI3vCY0LJcgWFg== X-Received: by 2002:a5d:5147:0:b0:21e:832e:7f0f with SMTP id u7-20020a5d5147000000b0021e832e7f0fmr7971116wrt.651.1658839557712; Tue, 26 Jul 2022 05:45:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:45:56 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:35 +0100 Message-Id: <20220726124549.1646-4-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 03/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/a* 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 --- .../raspberrypi/controller/agc_algorithm.hpp | 19 +++++++------- src/ipa/raspberrypi/controller/agc_status.h | 22 ++++++++-------- src/ipa/raspberrypi/controller/algorithm.cpp | 20 +++++++------- src/ipa/raspberrypi/controller/algorithm.hpp | 26 +++++++++---------- .../raspberrypi/controller/awb_algorithm.hpp | 6 ++--- src/ipa/raspberrypi/controller/awb_status.h | 8 +++--- 6 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/ipa/raspberrypi/controller/agc_algorithm.hpp b/src/ipa/raspberrypi/controller/agc_algorithm.hpp index 61595ea2b006..51900b687778 100644 --- a/src/ipa/raspberrypi/controller/agc_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/agc_algorithm.hpp @@ -17,16 +17,15 @@ class AgcAlgorithm : public Algorithm public: AgcAlgorithm(Controller *controller) : Algorithm(controller) {} // An AGC algorithm must provide the following: - virtual unsigned int GetConvergenceFrames() const = 0; - virtual void SetEv(double ev) = 0; - virtual void SetFlickerPeriod(libcamera::utils::Duration flicker_period) = 0; - virtual void SetFixedShutter(libcamera::utils::Duration fixed_shutter) = 0; - virtual void SetMaxShutter(libcamera::utils::Duration max_shutter) = 0; - virtual void SetFixedAnalogueGain(double fixed_analogue_gain) = 0; - virtual void SetMeteringMode(std::string const &metering_mode_name) = 0; - virtual void SetExposureMode(std::string const &exposure_mode_name) = 0; - virtual void - SetConstraintMode(std::string const &contraint_mode_name) = 0; + virtual unsigned int getConvergenceFrames() const = 0; + virtual void setEv(double ev) = 0; + virtual void setFlickerPeriod(libcamera::utils::Duration flickerPeriod) = 0; + virtual void setFixedShutter(libcamera::utils::Duration fixedShutter) = 0; + virtual void setMaxShutter(libcamera::utils::Duration maxShutter) = 0; + virtual void setFixedAnalogueGain(double fixedAnalogueGain) = 0; + virtual void setMeteringMode(std::string const &meteringModeName) = 0; + virtual void setExposureMode(std::string const &exposureModeName) = 0; + virtual void setConstraintMode(std::string const &contraintModeName) = 0; }; } // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/agc_status.h b/src/ipa/raspberrypi/controller/agc_status.h index 20cb1b624b33..5d04c61d04bd 100644 --- a/src/ipa/raspberrypi/controller/agc_status.h +++ b/src/ipa/raspberrypi/controller/agc_status.h @@ -20,19 +20,19 @@ extern "C" { // ignored until then. struct AgcStatus { - libcamera::utils::Duration total_exposure_value; // value for all exposure and gain for this image - libcamera::utils::Duration target_exposure_value; // (unfiltered) target total exposure AGC is aiming for - libcamera::utils::Duration shutter_time; - double analogue_gain; - char exposure_mode[32]; + libcamera::utils::Duration totalExposureValue; // value for all exposure and gain for this image + libcamera::utils::Duration targetExposureValue; // (unfiltered) target total exposure AGC is aiming for + libcamera::utils::Duration shutterTime; + double analogueGain; + char exposureMode[32]; char constraint_mode[32]; - char metering_mode[32]; + char meteringMode[32]; double ev; - libcamera::utils::Duration flicker_period; - int floating_region_enable; - libcamera::utils::Duration fixed_shutter; - double fixed_analogue_gain; - double digital_gain; + libcamera::utils::Duration flickerPeriod; + int floatingRegionEnable; + libcamera::utils::Duration fixedShutter; + double fixedAnalogueGain; + double digitalGain; int locked; }; diff --git a/src/ipa/raspberrypi/controller/algorithm.cpp b/src/ipa/raspberrypi/controller/algorithm.cpp index 43ad0a2be222..cfcd18a96c93 100644 --- a/src/ipa/raspberrypi/controller/algorithm.cpp +++ b/src/ipa/raspberrypi/controller/algorithm.cpp @@ -9,36 +9,38 @@ using namespace RPiController; -void Algorithm::Read([[maybe_unused]] boost::property_tree::ptree const ¶ms) +void Algorithm::read([[maybe_unused]] boost::property_tree::ptree const ¶ms) { } -void Algorithm::Initialise() {} +void Algorithm::initialise() +{ +} -void Algorithm::SwitchMode([[maybe_unused]] CameraMode const &camera_mode, +void Algorithm::switchMode([[maybe_unused]] CameraMode const &cameraMode, [[maybe_unused]] Metadata *metadata) { } -void Algorithm::Prepare([[maybe_unused]] Metadata *image_metadata) +void Algorithm::prepare([[maybe_unused]] Metadata *imageMetadata) { } -void Algorithm::Process([[maybe_unused]] StatisticsPtr &stats, - [[maybe_unused]] Metadata *image_metadata) +void Algorithm::process([[maybe_unused]] StatisticsPtr &stats, + [[maybe_unused]] Metadata *imageMetadata) { } // For registering algorithms with the system: static std::map algorithms; -std::map const &RPiController::GetAlgorithms() +std::map const &RPiController::getAlgorithms() { return algorithms; } RegisterAlgorithm::RegisterAlgorithm(char const *name, - AlgoCreateFunc create_func) + AlgoCreateFunc createFunc) { - algorithms[std::string(name)] = create_func; + algorithms[std::string(name)] = createFunc; } diff --git a/src/ipa/raspberrypi/controller/algorithm.hpp b/src/ipa/raspberrypi/controller/algorithm.hpp index 5123c87bab34..a33b14da2726 100644 --- a/src/ipa/raspberrypi/controller/algorithm.hpp +++ b/src/ipa/raspberrypi/controller/algorithm.hpp @@ -29,18 +29,18 @@ public: { } virtual ~Algorithm() = default; - virtual char const *Name() const = 0; - virtual bool IsPaused() const { return paused_; } - virtual void Pause() { paused_ = true; } - virtual void Resume() { paused_ = false; } - virtual void Read(boost::property_tree::ptree const ¶ms); - virtual void Initialise(); - virtual void SwitchMode(CameraMode const &camera_mode, Metadata *metadata); - virtual void Prepare(Metadata *image_metadata); - virtual void Process(StatisticsPtr &stats, Metadata *image_metadata); - Metadata &GetGlobalMetadata() const + virtual char const *name() const = 0; + virtual bool isPaused() const { return paused_; } + virtual void pause() { paused_ = true; } + virtual void resume() { paused_ = false; } + virtual void read(boost::property_tree::ptree const ¶ms); + virtual void initialise(); + virtual void switchMode(CameraMode const &cameraMode, Metadata *metadata); + virtual void prepare(Metadata *imageMetadata); + virtual void process(StatisticsPtr &stats, Metadata *imageMetadata); + Metadata &getGlobalMetadata() const { - return controller_->GetGlobalMetadata(); + return controller_->getGlobalMetadata(); } private: @@ -53,8 +53,8 @@ private: typedef Algorithm *(*AlgoCreateFunc)(Controller *controller); struct RegisterAlgorithm { - RegisterAlgorithm(char const *name, AlgoCreateFunc create_func); + RegisterAlgorithm(char const *name, AlgoCreateFunc createFunc); }; -std::map const &GetAlgorithms(); +std::map const &getAlgorithms(); } // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/awb_algorithm.hpp b/src/ipa/raspberrypi/controller/awb_algorithm.hpp index 96f88afc3a8d..c5d2ca90263c 100644 --- a/src/ipa/raspberrypi/controller/awb_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/awb_algorithm.hpp @@ -15,9 +15,9 @@ class AwbAlgorithm : public Algorithm public: AwbAlgorithm(Controller *controller) : Algorithm(controller) {} // An AWB algorithm must provide the following: - virtual unsigned int GetConvergenceFrames() const = 0; - virtual void SetMode(std::string const &mode_name) = 0; - virtual void SetManualGains(double manual_r, double manual_b) = 0; + virtual unsigned int getConvergenceFrames() const = 0; + virtual void setMode(std::string const &modeName) = 0; + virtual void setManualGains(double manualR, double manualB) = 0; }; } // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/awb_status.h b/src/ipa/raspberrypi/controller/awb_status.h index 46d7c842299a..bc428ed3206a 100644 --- a/src/ipa/raspberrypi/controller/awb_status.h +++ b/src/ipa/raspberrypi/controller/awb_status.h @@ -15,10 +15,10 @@ extern "C" { struct AwbStatus { char mode[32]; - double temperature_K; - double gain_r; - double gain_g; - double gain_b; + double temperatureK; + double gainR; + double gainG; + double gainB; }; #ifdef __cplusplus 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 From patchwork Tue Jul 26 12:45:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16778 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 94885C3275 for ; Tue, 26 Jul 2022 12:46:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A09463326; Tue, 26 Jul 2022 14:46:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839565; bh=lDvGYPRcazwRmcermwVxjPDD0hNDFO5mFeGMMesCWpE=; 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=WvutWdAi4tF40s/eNb7e0U6zjHYZ68mLy8X3UW27wg2i7kfl0/2fv31R6Y0OkbvbA CvEqwY2vzrueRwnuxLEnJ8ALV17Rac6RVsOyd1QDaW+GnDvMYsUbs/Tnkj0nSSrQoi tVEn1R51bGk/UF1QUraOAmzd5ktuvAtFYXnz11KhNyLi4/a1cm41HWTpi7CX+3Egqd q3X+IZOe5l3WsEmdpktHKPAj0kzYbTr+Z4IV4bI0eRFJmvOeef+gNvfCULV5zwBuO3 ytdtqjHcokjZ53/lVzQ5wubma2q5KlXzUpYIUealk1nFP04Yb4SW3qU3BQEYJ52cor WhtJQ0eRWJ5HQ== Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AF1A16330E for ; Tue, 26 Jul 2022 14:46:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="a74xHkTg"; dkim-atps=neutral Received: by mail-wr1-x429.google.com with SMTP id m17so19703732wrw.7 for ; Tue, 26 Jul 2022 05:46:00 -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=HyCZgSRw/lm8W2bEDr6DY60O+3rTN1NvLKjzS8uxivY=; b=a74xHkTgHhQspZrYfFX1qZSStWE/iIQ7k4BJNqNQdFsq45wJqbhn03rRLITq0UXtS6 Aaym9j+yGsj03ZI2LBJ0XOwXKOE4EkqRfTgtpya/KzEVVYepCKNQOm8/t5kDG4HsPTTH 4hPguPGC4Vf1shdogSaOZUTdL7GAcHntSB5PamgcfXTwoFJkilYmB8iVUMuRnHlprxiV 1MsZcGHUaCxjZ8BSNrv9FEK1nU81KkykSUVbhW2bJx1ffLm0zKmi7dl5YKIVHjeM8Lcd dQYhunJyk7T7lG/D7drUbyrm4YvodlFXNz7LpdwaYaWtUHiEjDAyv9DgIwM8pZof/M3B BaQg== 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=HyCZgSRw/lm8W2bEDr6DY60O+3rTN1NvLKjzS8uxivY=; b=xL0EIi7bv4qir7C9IcXi6eygyBEar76dw/2U2WdEbswpqrgk4ZJkDramG3iEyxEng0 DahOlr3SLjlMhJ9DFXrmPLqa7P/eqEZK/ax+0/6Z+ITqb094OdCwYGuFCc2WejYSplzN RE0FdvNsRtWMflp6yIxlBKVvLUmW7qRsFYjmI4WF9tYoMPi1FyPzYmd9sgUnB93BmZ6c P23ZpQdPG/TbkSAmECJX+m6I7L9RQNFaP+puJ9zcopcWojBjaklRGPSmhrY7ycs9EDmx OE8d2whwKELF8gJNZPwSRwg6DSjW8PbRY+pzDtktCq13BpzISAqI/QECGO01XpkgKorG 1BEQ== X-Gm-Message-State: AJIora8WWcIlVKtkq7AOUyHLryc/9cs0JOc+bKaBP5x/2XjzGTBzxK7D LdR5ifEodOUYKZOxugQYJYpLLOb5vzm9pw== X-Google-Smtp-Source: AGRyM1vxetiW3qfJk31A79PuF1Ts4/7J7eUDBRp4mfVcl5jsPALbEXJFgxg4/gMltUQWIONufFhxZg== X-Received: by 2002:a5d:6d0a:0:b0:21d:6f28:5ead with SMTP id e10-20020a5d6d0a000000b0021d6f285eadmr10611430wrq.95.1658839560009; Tue, 26 Jul 2022 05:46:00 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:45:59 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:37 +0100 Message-Id: <20220726124549.1646-6-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 05/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/d* 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 --- .../controller/denoise_algorithm.hpp | 2 +- .../raspberrypi/controller/denoise_status.h | 4 ++-- .../raspberrypi/controller/device_status.cpp | 18 +++++++++--------- src/ipa/raspberrypi/controller/device_status.h | 16 ++++++++-------- src/ipa/raspberrypi/controller/noise_status.h | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/ipa/raspberrypi/controller/denoise_algorithm.hpp b/src/ipa/raspberrypi/controller/denoise_algorithm.hpp index 39fcd7e94df2..48de542ac4f3 100644 --- a/src/ipa/raspberrypi/controller/denoise_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/denoise_algorithm.hpp @@ -17,7 +17,7 @@ class DenoiseAlgorithm : public Algorithm public: DenoiseAlgorithm(Controller *controller) : Algorithm(controller) {} // A Denoise algorithm must provide the following: - virtual void SetMode(DenoiseMode mode) = 0; + virtual void setMode(DenoiseMode mode) = 0; }; } // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/denoise_status.h b/src/ipa/raspberrypi/controller/denoise_status.h index 67a3c361387e..fe304d098253 100644 --- a/src/ipa/raspberrypi/controller/denoise_status.h +++ b/src/ipa/raspberrypi/controller/denoise_status.h @@ -13,8 +13,8 @@ extern "C" { #endif struct DenoiseStatus { - double noise_constant; - double noise_slope; + double noiseConstant; + double noiseSlope; double strength; unsigned int mode; }; diff --git a/src/ipa/raspberrypi/controller/device_status.cpp b/src/ipa/raspberrypi/controller/device_status.cpp index a389c40dafed..f8ed77354a0a 100644 --- a/src/ipa/raspberrypi/controller/device_status.cpp +++ b/src/ipa/raspberrypi/controller/device_status.cpp @@ -10,21 +10,21 @@ using namespace libcamera; /* for the Duration operator<< overload */ std::ostream &operator<<(std::ostream &out, const DeviceStatus &d) { - out << "Exposure: " << d.shutter_speed - << " Frame length: " << d.frame_length - << " Gain: " << d.analogue_gain; + out << "Exposure: " << d.shutterSpeed + << " Frame length: " << d.frameLength + << " Gain: " << d.analogueGain; if (d.aperture) out << " Aperture: " << *d.aperture; - if (d.lens_position) - out << " Lens: " << *d.lens_position; + if (d.lensPosition) + out << " Lens: " << *d.lensPosition; - if (d.flash_intensity) - out << " Flash: " << *d.flash_intensity; + if (d.flashIntensity) + out << " Flash: " << *d.flashIntensity; - if (d.sensor_temperature) - out << " Temperature: " << *d.sensor_temperature; + if (d.sensorTemperature) + out << " Temperature: " << *d.sensorTemperature; return out; } diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index b33f0d093ff3..ebcd7da2586b 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -18,24 +18,24 @@ struct DeviceStatus { DeviceStatus() - : shutter_speed(std::chrono::seconds(0)), frame_length(0), - analogue_gain(0.0) + : shutterSpeed(std::chrono::seconds(0)), frameLength(0), + analogueGain(0.0) { } friend std::ostream &operator<<(std::ostream &out, const DeviceStatus &d); /* time shutter is open */ - libcamera::utils::Duration shutter_speed; + libcamera::utils::Duration shutterSpeed; /* frame length given in number of lines */ - uint32_t frame_length; - double analogue_gain; + uint32_t frameLength; + double analogueGain; /* 1.0/distance-in-metres, or 0 if unknown */ - std::optional lens_position; + std::optional lensPosition; /* 1/f so that brightness quadruples when this doubles, or 0 if unknown */ std::optional aperture; /* proportional to brightness with 0 = no flash, 1 = maximum flash */ - std::optional flash_intensity; + std::optional flashIntensity; /* Sensor reported temperature value (in degrees) */ - std::optional sensor_temperature; + std::optional sensorTemperature; }; diff --git a/src/ipa/raspberrypi/controller/noise_status.h b/src/ipa/raspberrypi/controller/noise_status.h index 8439a40213aa..358af4fe869b 100644 --- a/src/ipa/raspberrypi/controller/noise_status.h +++ b/src/ipa/raspberrypi/controller/noise_status.h @@ -13,8 +13,8 @@ extern "C" { #endif struct NoiseStatus { - double noise_constant; - double noise_slope; + double noiseConstant; + double noiseSlope; }; #ifdef __cplusplus From patchwork Tue Jul 26 12:45:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16779 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 7A4FEC3275 for ; Tue, 26 Jul 2022 12:46:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A6CA6332B; Tue, 26 Jul 2022 14:46:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839567; bh=tvjJHZ+plL7sB79EGe6TDzoz6/Qzo3yZyANxQynqMu8=; 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=nPP+nyad4+BBHhBvBJnD1iyEAkz5HNrSgRrRfXkNYe5Nyi3XX8sGQXZQx9+bWBmR/ T80/+6d8Cb/xMRHqhyJmR2AikuHyBFRSJYLUZV9q4AXFScmfhlviuH0z4RXtOW3w/c jgoobvsNzyu6vrDClK4BJKMfwbrwicesAH1/qaYt4wlvSVcslxNA/bfUS2pc9jyV28 llnaObi2urumiQvJQA4O5kQGfg2c9Zd/Vf61zj8NLGGP2mYL5edWvKl0dSf0M6Yd6n MfVIWZ3QpRYLM1tbUyadSbjTHRujYxXukT3Rzk5eRQfLFGXVXEOeyxOrldGBaMNjLV CiTJlU605437A== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E27976330E for ; Tue, 26 Jul 2022 14:46:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ED7QIkkR"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id d8so19897799wrp.6 for ; Tue, 26 Jul 2022 05:46:01 -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=RlwY6NXz6rifN0Yl9JslSeOg5YGng+ng+HGwpi07rlA=; b=ED7QIkkRBj+ytdahrfmbGd9qAfK4G6tt85DtnICxiJn7eUEihhmjxJgrwEHMu7C7LC IYvgtjnWxJDpqf6PQ4upfE0jbDY3zuMXKAK+Of4eymqg/kuuTQurxT+nwScP8M1oeRwq T25O9zX2r/6ha788BEe0eDROvJ4Xc9cygyfJT4Q76Ea3fZOCm8ysULscXk0EISSZn+6S 8sk47WmgFrfgC1si5lgLKrpRrfh1rkYEEYO3lMaPzXYJYaAi/OufCt+jssWNVcc0uBI2 Dg4lS+Pwg+CSssyCmUclUlaZtDCLSfVv/jxdypR/yqiGNoWlLTwD7p7eD3nsIx711XVw OikQ== 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=RlwY6NXz6rifN0Yl9JslSeOg5YGng+ng+HGwpi07rlA=; b=dqiv+po5JThbVRWEKWD4BYmyygdJTq3qNaro0+RJtWbU04AgdJ0AroGmEUPxTz8IyJ ghKIPMUL449fF3y4Ul8J1ZbZGVUWEkull4ii07fNRB97fJnIsr80RyQmEjHZF5OYY5XL C8ZcP7hKhldkhtuCiDqO0/G2cOVPHhLJso067CgHAFt1Iml69WbvyXRh20D4JiDjPUOX w+PggC+rrO1Vg73TUzh0tpzd63cyeioLJZYXeXXTVUxZkRhderQNtIeJU0CVsWCJETZb /PyQ65X3rINpgHiCwIkOjHVeMlwq4GWJaG6w6XFnPXQYM2VQMHOFk5gwt9QFx59r8bbj p0uQ== X-Gm-Message-State: AJIora/7W47EMLoT6zVMGy54lE8HwYa9DXW8DsFPZ2BY++cbLusJEIeU t54vsOGnxS2+u5HyrGGugBW1zGE7LVDPiQ== X-Google-Smtp-Source: AGRyM1s/wDtcE69d4rVQID8tbrqr+dVtZbnewM74Kbt9eCD0ZZduXIKgn19D3v2tOOsNgkC5sRjEIw== X-Received: by 2002:a05:6000:986:b0:21e:939b:a71 with SMTP id by6-20020a056000098600b0021e939b0a71mr4588549wrb.256.1658839560964; Tue, 26 Jul 2022 05:46:00 -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.46.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:46:00 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:38 +0100 Message-Id: <20220726124549.1646-7-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 06/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 remaining files under src/ipa/raspberrypi/controller/* 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/focus_status.h | 2 +- src/ipa/raspberrypi/controller/histogram.cpp | 34 ++--- src/ipa/raspberrypi/controller/histogram.hpp | 10 +- src/ipa/raspberrypi/controller/metadata.hpp | 16 +-- src/ipa/raspberrypi/controller/pwl.cpp | 130 +++++++++--------- src/ipa/raspberrypi/controller/pwl.hpp | 48 +++---- 6 files changed, 121 insertions(+), 119 deletions(-) diff --git a/src/ipa/raspberrypi/controller/focus_status.h b/src/ipa/raspberrypi/controller/focus_status.h index ace2fe2c317a..656455100b45 100644 --- a/src/ipa/raspberrypi/controller/focus_status.h +++ b/src/ipa/raspberrypi/controller/focus_status.h @@ -18,7 +18,7 @@ extern "C" { struct FocusStatus { unsigned int num; - uint32_t focus_measures[FOCUS_REGIONS]; + uint32_t focusMeasures[FOCUS_REGIONS]; }; #ifdef __cplusplus diff --git a/src/ipa/raspberrypi/controller/histogram.cpp b/src/ipa/raspberrypi/controller/histogram.cpp index 9916b3ed7f71..e865bef0057b 100644 --- a/src/ipa/raspberrypi/controller/histogram.cpp +++ b/src/ipa/raspberrypi/controller/histogram.cpp @@ -11,25 +11,25 @@ using namespace RPiController; -uint64_t Histogram::CumulativeFreq(double bin) const +uint64_t Histogram::cumulativeFreq(double bin) const { if (bin <= 0) return 0; - else if (bin >= Bins()) - return Total(); + else if (bin >= bins()) + return total(); int b = (int)bin; return cumulative_[b] + (bin - b) * (cumulative_[b + 1] - cumulative_[b]); } -double Histogram::Quantile(double q, int first, int last) const +double Histogram::quantile(double q, int first, int last) const { if (first == -1) first = 0; if (last == -1) last = cumulative_.size() - 2; assert(first <= last); - uint64_t items = q * Total(); + uint64_t items = q * total(); while (first < last) // binary search to find the right bin { int middle = (first + last) / 2; @@ -45,20 +45,20 @@ double Histogram::Quantile(double q, int first, int last) const return first + frac; } -double Histogram::InterQuantileMean(double q_lo, double q_hi) const +double Histogram::interQuantileMean(double qLo, double qHi) const { - assert(q_hi > q_lo); - double p_lo = Quantile(q_lo); - double p_hi = Quantile(q_hi, (int)p_lo); - double sum_bin_freq = 0, cumul_freq = 0; - for (double p_next = floor(p_lo) + 1.0; p_next <= ceil(p_hi); - p_lo = p_next, p_next += 1.0) { - int bin = floor(p_lo); + assert(qHi > qLo); + double pLo = quantile(qLo); + double pHi = quantile(qHi, (int)pLo); + double sumBinFreq = 0, cumulFreq = 0; + for (double pNext = floor(pLo) + 1.0; pNext <= ceil(pHi); + pLo = pNext, pNext += 1.0) { + int bin = floor(pLo); double freq = (cumulative_[bin + 1] - cumulative_[bin]) * - (std::min(p_next, p_hi) - p_lo); - sum_bin_freq += bin * freq; - cumul_freq += freq; + (std::min(pNext, pHi) - pLo); + sumBinFreq += bin * freq; + cumulFreq += freq; } // add 0.5 to give an average for bin mid-points - return sum_bin_freq / cumul_freq + 0.5; + return sumBinFreq / cumulFreq + 0.5; } diff --git a/src/ipa/raspberrypi/controller/histogram.hpp b/src/ipa/raspberrypi/controller/histogram.hpp index 90f5ac78e8c6..4ff5a56b0243 100644 --- a/src/ipa/raspberrypi/controller/histogram.hpp +++ b/src/ipa/raspberrypi/controller/histogram.hpp @@ -27,15 +27,15 @@ public: cumulative_.push_back(cumulative_.back() + histogram[i]); } - uint32_t Bins() const { return cumulative_.size() - 1; } - uint64_t Total() const { return cumulative_[cumulative_.size() - 1]; } + uint32_t bins() const { return cumulative_.size() - 1; } + uint64_t total() const { return cumulative_[cumulative_.size() - 1]; } // Cumulative frequency up to a (fractional) point in a bin. - uint64_t CumulativeFreq(double bin) const; + uint64_t cumulativeFreq(double bin) const; // Return the (fractional) bin of the point q (0 <= q <= 1) through the // histogram. Optionally provide limits to help. - double Quantile(double q, int first = -1, int last = -1) const; + double quantile(double q, int first = -1, int last = -1) const; // Return the average histogram bin value between the two quantiles. - double InterQuantileMean(double q_lo, double q_hi) const; + double interQuantileMean(double qLo, double qHi) const; private: std::vector cumulative_; diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp index 51e576cfab95..a79a67d42cce 100644 --- a/src/ipa/raspberrypi/controller/metadata.hpp +++ b/src/ipa/raspberrypi/controller/metadata.hpp @@ -22,26 +22,26 @@ public: Metadata(Metadata const &other) { - std::scoped_lock other_lock(other.mutex_); + std::scoped_lock otherLock(other.mutex_); data_ = other.data_; } Metadata(Metadata &&other) { - std::scoped_lock other_lock(other.mutex_); + std::scoped_lock otherLock(other.mutex_); data_ = std::move(other.data_); other.data_.clear(); } template - void Set(std::string const &tag, T const &value) + void set(std::string const &tag, T const &value) { std::scoped_lock lock(mutex_); data_[tag] = value; } template - int Get(std::string const &tag, T &value) const + int get(std::string const &tag, T &value) const { std::scoped_lock lock(mutex_); auto it = data_.find(tag); @@ -51,7 +51,7 @@ public: return 0; } - void Clear() + void clear() { std::scoped_lock lock(mutex_); data_.clear(); @@ -72,14 +72,14 @@ public: return *this; } - void Merge(Metadata &other) + void merge(Metadata &other) { std::scoped_lock lock(mutex_, other.mutex_); data_.merge(other.data_); } template - T *GetLocked(std::string const &tag) + T *getLocked(std::string const &tag) { // This allows in-place access to the Metadata contents, // for which you should be holding the lock. @@ -90,7 +90,7 @@ public: } template - void SetLocked(std::string const &tag, T const &value) + void setLocked(std::string const &tag, T const &value) { // Use this only if you're holding the lock yourself. data_[tag] = value; diff --git a/src/ipa/raspberrypi/controller/pwl.cpp b/src/ipa/raspberrypi/controller/pwl.cpp index 130c820b559f..24ff3ea34f5f 100644 --- a/src/ipa/raspberrypi/controller/pwl.cpp +++ b/src/ipa/raspberrypi/controller/pwl.cpp @@ -12,7 +12,7 @@ using namespace RPiController; -void Pwl::Read(boost::property_tree::ptree const ¶ms) +void Pwl::read(boost::property_tree::ptree const ¶ms) { for (auto it = params.begin(); it != params.end(); it++) { double x = it->second.get_value(); @@ -24,24 +24,24 @@ void Pwl::Read(boost::property_tree::ptree const ¶ms) assert(points_.size() >= 2); } -void Pwl::Append(double x, double y, const double eps) +void Pwl::append(double x, double y, const double eps) { if (points_.empty() || points_.back().x + eps < x) points_.push_back(Point(x, y)); } -void Pwl::Prepend(double x, double y, const double eps) +void Pwl::prepend(double x, double y, const double eps) { if (points_.empty() || points_.front().x - eps > x) points_.insert(points_.begin(), Point(x, y)); } -Pwl::Interval Pwl::Domain() const +Pwl::Interval Pwl::domain() const { return Interval(points_[0].x, points_[points_.size() - 1].x); } -Pwl::Interval Pwl::Range() const +Pwl::Interval Pwl::range() const { double lo = points_[0].y, hi = lo; for (auto &p : points_) @@ -49,18 +49,16 @@ Pwl::Interval Pwl::Range() const return Interval(lo, hi); } -bool Pwl::Empty() const +bool Pwl::empty() const { return points_.empty(); } -double Pwl::Eval(double x, int *span_ptr, bool update_span) const +double Pwl::eval(double x, int *spanPtr, bool updateSpan) const { - int span = findSpan(x, span_ptr && *span_ptr != -1 - ? *span_ptr - : points_.size() / 2 - 1); - if (span_ptr && update_span) - *span_ptr = span; + int span = findSpan(x, spanPtr && *spanPtr != -1 ? *spanPtr : points_.size() / 2 - 1); + if (spanPtr && updateSpan) + *spanPtr = span; return points_[span].y + (x - points_[span].x) * (points_[span + 1].y - points_[span].y) / (points_[span + 1].x - points_[span].x); @@ -70,31 +68,31 @@ int Pwl::findSpan(double x, int span) const { // Pwls are generally small, so linear search may well be faster than // binary, though could review this if large PWls start turning up. - int last_span = points_.size() - 2; + int lastSpan = points_.size() - 2; // some algorithms may call us with span pointing directly at the last // control point - span = std::max(0, std::min(last_span, span)); - while (span < last_span && x >= points_[span + 1].x) + span = std::max(0, std::min(lastSpan, span)); + while (span < lastSpan && x >= points_[span + 1].x) span++; while (span && x < points_[span].x) span--; return span; } -Pwl::PerpType Pwl::Invert(Point const &xy, Point &perp, int &span, +Pwl::PerpType Pwl::invert(Point const &xy, Point &perp, int &span, const double eps) const { assert(span >= -1); - bool prev_off_end = false; + bool prevOffEnd = false; for (span = span + 1; span < (int)points_.size() - 1; span++) { - Point span_vec = points_[span + 1] - points_[span]; - double t = ((xy - points_[span]) % span_vec) / span_vec.Len2(); + Point spanVec = points_[span + 1] - points_[span]; + double t = ((xy - points_[span]) % spanVec) / spanVec.len2(); if (t < -eps) // off the start of this span { if (span == 0) { perp = points_[span]; return PerpType::Start; - } else if (prev_off_end) { + } else if (prevOffEnd) { perp = points_[span]; return PerpType::Vertex; } @@ -104,32 +102,32 @@ Pwl::PerpType Pwl::Invert(Point const &xy, Point &perp, int &span, perp = points_[span + 1]; return PerpType::End; } - prev_off_end = true; + prevOffEnd = true; } else // a true perpendicular { - perp = points_[span] + span_vec * t; + perp = points_[span] + spanVec * t; return PerpType::Perpendicular; } } return PerpType::None; } -Pwl Pwl::Inverse(bool *true_inverse, const double eps) const +Pwl Pwl::inverse(bool *trueInverse, const double eps) const { bool appended = false, prepended = false, neither = false; Pwl inverse; for (Point const &p : points_) { - if (inverse.Empty()) - inverse.Append(p.y, p.x, eps); + if (inverse.empty()) + inverse.append(p.y, p.x, eps); else if (std::abs(inverse.points_.back().x - p.y) <= eps || std::abs(inverse.points_.front().x - p.y) <= eps) /* do nothing */; else if (p.y > inverse.points_.back().x) { - inverse.Append(p.y, p.x, eps); + inverse.append(p.y, p.x, eps); appended = true; } else if (p.y < inverse.points_.front().x) { - inverse.Prepend(p.y, p.x, eps); + inverse.prepend(p.y, p.x, eps); prepended = true; } else neither = true; @@ -138,63 +136,65 @@ Pwl Pwl::Inverse(bool *true_inverse, const double eps) const // This is not a proper inverse if we found ourselves putting points // onto both ends of the inverse, or if there were points that couldn't // go on either. - if (true_inverse) - *true_inverse = !(neither || (appended && prepended)); + if (trueInverse) + *trueInverse = !(neither || (appended && prepended)); return inverse; } -Pwl Pwl::Compose(Pwl const &other, const double eps) const +Pwl Pwl::compose(Pwl const &other, const double eps) const { - double this_x = points_[0].x, this_y = points_[0].y; - int this_span = 0, other_span = other.findSpan(this_y, 0); - Pwl result({ { this_x, other.Eval(this_y, &other_span, false) } }); - while (this_span != (int)points_.size() - 1) { - double dx = points_[this_span + 1].x - points_[this_span].x, - dy = points_[this_span + 1].y - points_[this_span].y; + double thisX = points_[0].x, thisY = points_[0].y; + int thisSpan = 0, otherSpan = other.findSpan(thisY, 0); + Pwl result({ { thisX, other.eval(thisY, &otherSpan, false) } }); + while (thisSpan != (int)points_.size() - 1) { + double dx = points_[thisSpan + 1].x - points_[thisSpan].x, + dy = points_[thisSpan + 1].y - points_[thisSpan].y; if (abs(dy) > eps && - other_span + 1 < (int)other.points_.size() && - points_[this_span + 1].y >= - other.points_[other_span + 1].x + eps) { + otherSpan + 1 < (int)other.points_.size() && + points_[thisSpan + 1].y >= + other.points_[otherSpan + 1].x + eps) { // next control point in result will be where this // function's y reaches the next span in other - this_x = points_[this_span].x + - (other.points_[other_span + 1].x - - points_[this_span].y) * dx / dy; - this_y = other.points_[++other_span].x; - } else if (abs(dy) > eps && other_span > 0 && - points_[this_span + 1].y <= - other.points_[other_span - 1].x - eps) { + thisX = points_[thisSpan].x + + (other.points_[otherSpan + 1].x - + points_[thisSpan].y) * + dx / dy; + thisY = other.points_[++otherSpan].x; + } else if (abs(dy) > eps && otherSpan > 0 && + points_[thisSpan + 1].y <= + other.points_[otherSpan - 1].x - eps) { // next control point in result will be where this // function's y reaches the previous span in other - this_x = points_[this_span].x + - (other.points_[other_span + 1].x - - points_[this_span].y) * dx / dy; - this_y = other.points_[--other_span].x; + thisX = points_[thisSpan].x + + (other.points_[otherSpan + 1].x - + points_[thisSpan].y) * + dx / dy; + thisY = other.points_[--otherSpan].x; } else { // we stay in the same span in other - this_span++; - this_x = points_[this_span].x, - this_y = points_[this_span].y; + thisSpan++; + thisX = points_[thisSpan].x, + thisY = points_[thisSpan].y; } - result.Append(this_x, other.Eval(this_y, &other_span, false), + result.append(thisX, other.eval(thisY, &otherSpan, false), eps); } return result; } -void Pwl::Map(std::function f) const +void Pwl::map(std::function f) const { for (auto &pt : points_) f(pt.x, pt.y); } -void Pwl::Map2(Pwl const &pwl0, Pwl const &pwl1, +void Pwl::map2(Pwl const &pwl0, Pwl const &pwl1, std::function f) { int span0 = 0, span1 = 0; double x = std::min(pwl0.points_[0].x, pwl1.points_[0].x); - f(x, pwl0.Eval(x, &span0, false), pwl1.Eval(x, &span1, false)); + f(x, pwl0.eval(x, &span0, false), pwl1.eval(x, &span1, false)); while (span0 < (int)pwl0.points_.size() - 1 || span1 < (int)pwl1.points_.size() - 1) { if (span0 == (int)pwl0.points_.size() - 1) @@ -205,28 +205,28 @@ void Pwl::Map2(Pwl const &pwl0, Pwl const &pwl1, x = pwl1.points_[++span1].x; else x = pwl0.points_[++span0].x; - f(x, pwl0.Eval(x, &span0, false), pwl1.Eval(x, &span1, false)); + f(x, pwl0.eval(x, &span0, false), pwl1.eval(x, &span1, false)); } } -Pwl Pwl::Combine(Pwl const &pwl0, Pwl const &pwl1, +Pwl Pwl::combine(Pwl const &pwl0, Pwl const &pwl1, std::function f, const double eps) { Pwl result; - Map2(pwl0, pwl1, [&](double x, double y0, double y1) { - result.Append(x, f(x, y0, y1), eps); + map2(pwl0, pwl1, [&](double x, double y0, double y1) { + result.append(x, f(x, y0, y1), eps); }); return result; } -void Pwl::MatchDomain(Interval const &domain, bool clip, const double eps) +void Pwl::matchDomain(Interval const &domain, bool clip, const double eps) { int span = 0; - Prepend(domain.start, Eval(clip ? points_[0].x : domain.start, &span), + prepend(domain.start, eval(clip ? points_[0].x : domain.start, &span), eps); span = points_.size() - 2; - Append(domain.end, Eval(clip ? points_.back().x : domain.end, &span), + append(domain.end, eval(clip ? points_.back().x : domain.end, &span), eps); } @@ -237,7 +237,7 @@ Pwl &Pwl::operator*=(double d) return *this; } -void Pwl::Debug(FILE *fp) const +void Pwl::debug(FILE *fp) const { fprintf(fp, "Pwl {\n"); for (auto &p : points_) diff --git a/src/ipa/raspberrypi/controller/pwl.hpp b/src/ipa/raspberrypi/controller/pwl.hpp index 484672f64095..4a38d1df5a33 100644 --- a/src/ipa/raspberrypi/controller/pwl.hpp +++ b/src/ipa/raspberrypi/controller/pwl.hpp @@ -17,24 +17,26 @@ class Pwl { public: struct Interval { - Interval(double _start, double _end) : start(_start), end(_end) + Interval(double _start, double _end) + : start(_start), end(_end) { } double start, end; - bool Contains(double value) + bool contains(double value) { return value >= start && value <= end; } - double Clip(double value) + double clip(double value) { return value < start ? start : (value > end ? end : value); } - double Len() const { return end - start; } + double len() const { return end - start; } }; struct Point { Point() : x(0), y(0) {} - Point(double _x, double _y) : x(_x), y(_y) {} + Point(double _x, double _y) + : x(_x), y(_y) {} double x, y; Point operator-(Point const &p) const { @@ -50,23 +52,23 @@ public: } Point operator*(double f) const { return Point(x * f, y * f); } Point operator/(double f) const { return Point(x / f, y / f); } - double Len2() const { return x * x + y * y; } - double Len() const { return sqrt(Len2()); } + double len2() const { return x * x + y * y; } + double len() const { return sqrt(len2()); } }; Pwl() {} Pwl(std::vector const &points) : points_(points) {} - void Read(boost::property_tree::ptree const ¶ms); - void Append(double x, double y, const double eps = 1e-6); - void Prepend(double x, double y, const double eps = 1e-6); - Interval Domain() const; - Interval Range() const; - bool Empty() const; + void read(boost::property_tree::ptree const ¶ms); + void append(double x, double y, const double eps = 1e-6); + void prepend(double x, double y, const double eps = 1e-6); + Interval domain() const; + Interval range() const; + bool empty() const; // Evaluate Pwl, optionally supplying an initial guess for the // "span". The "span" may be optionally be updated. If you want to know // the "span" value but don't have an initial guess you can set it to // -1. - double Eval(double x, int *span_ptr = nullptr, - bool update_span = true) const; + double eval(double x, int *spanPtr = nullptr, + bool updateSpan = true) const; // Find perpendicular closest to xy, starting from span+1 so you can // call it repeatedly to check for multiple closest points (set span to // -1 on the first call). Also returns "pseudo" perpendiculars; see @@ -78,31 +80,31 @@ public: Vertex, // vertex of Pwl is closest point Perpendicular // true perpendicular found }; - PerpType Invert(Point const &xy, Point &perp, int &span, + PerpType invert(Point const &xy, Point &perp, int &span, const double eps = 1e-6) const; // Compute the inverse function. Indicate if it is a proper (true) // inverse, or only a best effort (e.g. input was non-monotonic). - Pwl Inverse(bool *true_inverse = nullptr, const double eps = 1e-6) const; + Pwl inverse(bool *trueInverse = nullptr, const double eps = 1e-6) const; // Compose two Pwls together, doing "this" first and "other" after. - Pwl Compose(Pwl const &other, const double eps = 1e-6) const; + Pwl compose(Pwl const &other, const double eps = 1e-6) const; // Apply function to (x,y) values at every control point. - void Map(std::function f) const; + void map(std::function f) const; // Apply function to (x, y0, y1) values wherever either Pwl has a // control point. - static void Map2(Pwl const &pwl0, Pwl const &pwl1, + static void map2(Pwl const &pwl0, Pwl const &pwl1, std::function f); // Combine two Pwls, meaning we create a new Pwl where the y values are // given by running f wherever either has a knot. static Pwl - Combine(Pwl const &pwl0, Pwl const &pwl1, + combine(Pwl const &pwl0, Pwl const &pwl1, std::function f, const double eps = 1e-6); // Make "this" match (at least) the given domain. Any extension my be // clipped or linear. - void MatchDomain(Interval const &domain, bool clip = true, + void matchDomain(Interval const &domain, bool clip = true, const double eps = 1e-6); Pwl &operator*=(double d); - void Debug(FILE *fp = stdout) const; + void debug(FILE *fp = stdout) const; private: int findSpan(double x, int span) const; From patchwork Tue Jul 26 12:45:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16780 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 261E5C3275 for ; Tue, 26 Jul 2022 12:46:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B181C6332A; Tue, 26 Jul 2022 14:46:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839567; bh=RJTlSJIlOaoylyqv3TvK8s/+oAra1/pNU0qLmRhDNJk=; 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=iRlY2vv1t/5sqGk97Ywz7tlxqkmTO301CTyebgvTW3pvmEiMOH9pKtA34NZUjvWXl /+xINRG4mgUNqkfGbErW9UDinNt47Ft4F9NSZKhou499nbeU5lzsM6pXgJU5idES2E JRJVPcdBxKDYJyrCwr+4Si+wHrqMXp4nDsMn4Ur1ETrDcO5vH1GbQ9h5cJ88DLx8Ge fb8vTnkVKQ8muLmvPRZwbnqaElqbU6lpf67VjvRL4dhK1F2EUxSDy/FKVw3YYQ5UN3 iX+Zcxfq0fe/FZd2fIC6+6s6Y9GaagTxdPtVi+C+y7HdjmsWXAcKaVqSIfb2h5Mtsy bJfVULY5pt3IQ== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 90C2D63311 for ; Tue, 26 Jul 2022 14:46:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Tepmmb82"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id d8so19898000wrp.6 for ; Tue, 26 Jul 2022 05:46:04 -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=F9NsWG0phcemJBLSf0RPFBdtK7aaHslP7W/OuaDJy2g=; b=Tepmmb82dBD/qeyoH1vSzXVaKHn3wr9JOUtiwtp45rpHW/l09w/IycN7ZBzlZziPjI 1xyunLJnlgZI7if3SrGVaHQ04EoJc9K+OuaQzTLM3/BGclAHly+byNDYKPbGI2ietHG3 Z1N2oCHwriQZR3HZx55hBjXuR6+ZIIir/L6d6eZtEnHyvwQCQuPnBeA3d7p74bSGM4nq O4534oCPNMmwKDIufUC7arvzx61rAkdCD2BUBPDXTTFP1ppnGNoJVo8XeGxqxPADD9O8 Tz3kWCZadOUjGPxQuqquAwOnSuQqLKtfvnnq7ZAdZ1pm8ZyeVlVxHvLqepAHkilhN3tq /GnQ== 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=F9NsWG0phcemJBLSf0RPFBdtK7aaHslP7W/OuaDJy2g=; b=mTJg6XqRJ1HH2CMArggv6WAW2NLzjjgTscQ6ag40D5xs8ujf6EUmE6pFhUUZ32cdnK 36f2ro2/RuhHcV0hJ+ZSdNEnmmVPDxQ3tMKQwuGUKVySSRC+39bUgVksca9pgBDR87T1 Y6L6hqR7WoUwtxrjmOtKiOxbzStODcmRXQ6YPx092ss7T1sUfAKOwS+qD+dRtaqPkD6z N3IewgSHHxEWtzMF8MtqgPs9+EKgh/KFCxgmzcMau62HrdVrtEX5U8kwDAzEctotTSxT dnhXVoIFoiaVSJQ97vAB/NhXzqk6wHLT856hOH0qSMx6iAXJGKon5N9fKko2V7gBt4YV gKAw== X-Gm-Message-State: AJIora/n2XJtDpeXFCKpYSJMbPavhkTjl0/W6iKASTwFDVMo+By40uke mjGGdQSxNPGz9SjN7R0rzXFtNi/l4LK/Cg== X-Google-Smtp-Source: AGRyM1u/wDct9+7Im+urHJXn/UBB5sCPN9f6chq1/4O011djoUPWPM6ithcd3KHTllxqxUZExnRdvA== X-Received: by 2002:a05:6000:508:b0:21d:4105:caf9 with SMTP id a8-20020a056000050800b0021d4105caf9mr11097441wrf.699.1658839562370; Tue, 26 Jul 2022 05:46:02 -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.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:46:01 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:39 +0100 Message-Id: <20220726124549.1646-8-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 07/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/rpi/a* 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/agc_status.h | 2 +- src/ipa/raspberrypi/controller/rpi/agc.cpp | 732 ++++++++++---------- src/ipa/raspberrypi/controller/rpi/agc.hpp | 130 ++-- src/ipa/raspberrypi/controller/rpi/alsc.cpp | 641 ++++++++--------- src/ipa/raspberrypi/controller/rpi/alsc.hpp | 86 +-- src/ipa/raspberrypi/controller/rpi/awb.cpp | 564 ++++++++------- src/ipa/raspberrypi/controller/rpi/awb.hpp | 110 +-- 7 files changed, 1097 insertions(+), 1168 deletions(-) diff --git a/src/ipa/raspberrypi/controller/agc_status.h b/src/ipa/raspberrypi/controller/agc_status.h index 5d04c61d04bd..d36b40d841db 100644 --- a/src/ipa/raspberrypi/controller/agc_status.h +++ b/src/ipa/raspberrypi/controller/agc_status.h @@ -25,7 +25,7 @@ struct AgcStatus { libcamera::utils::Duration shutterTime; double analogueGain; char exposureMode[32]; - char constraint_mode[32]; + char constraintMode[32]; char meteringMode[32]; double ev; libcamera::utils::Duration flickerPeriod; diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index f6a9cb0a2cd8..c19769f4e27b 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -30,7 +30,7 @@ LOG_DEFINE_CATEGORY(RPiAgc) #define PIPELINE_BITS 13 // seems to be a 13-bit pipeline -void AgcMeteringMode::Read(boost::property_tree::ptree const ¶ms) +void AgcMeteringMode::read(boost::property_tree::ptree const ¶ms) { int num = 0; for (auto &p : params.get_child("weights")) { @@ -43,265 +43,260 @@ void AgcMeteringMode::Read(boost::property_tree::ptree const ¶ms) } static std::string -read_metering_modes(std::map &metering_modes, - boost::property_tree::ptree const ¶ms) +readMeteringModes(std::map &meteringModes, + boost::property_tree::ptree const ¶ms) { std::string first; for (auto &p : params) { - AgcMeteringMode metering_mode; - metering_mode.Read(p.second); - metering_modes[p.first] = std::move(metering_mode); + AgcMeteringMode meteringMode; + meteringMode.read(p.second); + meteringModes[p.first] = std::move(meteringMode); if (first.empty()) first = p.first; } return first; } -static int read_list(std::vector &list, - boost::property_tree::ptree const ¶ms) +static int readList(std::vector &list, + boost::property_tree::ptree const ¶ms) { for (auto &p : params) list.push_back(p.second.get_value()); return list.size(); } -static int read_list(std::vector &list, - boost::property_tree::ptree const ¶ms) +static int readList(std::vector &list, + boost::property_tree::ptree const ¶ms) { for (auto &p : params) list.push_back(p.second.get_value() * 1us); return list.size(); } -void AgcExposureMode::Read(boost::property_tree::ptree const ¶ms) +void AgcExposureMode::read(boost::property_tree::ptree const ¶ms) { - int num_shutters = read_list(shutter, params.get_child("shutter")); - int num_ags = read_list(gain, params.get_child("gain")); - if (num_shutters < 2 || num_ags < 2) + int numShutters = readList(shutter, params.get_child("shutter")); + int numAgs = readList(gain, params.get_child("gain")); + if (numShutters < 2 || numAgs < 2) throw std::runtime_error( "AgcConfig: must have at least two entries in exposure profile"); - if (num_shutters != num_ags) + if (numShutters != numAgs) throw std::runtime_error( "AgcConfig: expect same number of exposure and gain entries in exposure profile"); } static std::string -read_exposure_modes(std::map &exposure_modes, - boost::property_tree::ptree const ¶ms) +readExposureModes(std::map &exposureModes, + boost::property_tree::ptree const ¶ms) { std::string first; for (auto &p : params) { - AgcExposureMode exposure_mode; - exposure_mode.Read(p.second); - exposure_modes[p.first] = std::move(exposure_mode); + AgcExposureMode exposureMode; + exposureMode.read(p.second); + exposureModes[p.first] = std::move(exposureMode); if (first.empty()) first = p.first; } return first; } -void AgcConstraint::Read(boost::property_tree::ptree const ¶ms) +void AgcConstraint::read(boost::property_tree::ptree const ¶ms) { - std::string bound_string = params.get("bound", ""); - transform(bound_string.begin(), bound_string.end(), - bound_string.begin(), ::toupper); - if (bound_string != "UPPER" && bound_string != "LOWER") + std::string boundString = params.get("bound", ""); + transform(boundString.begin(), boundString.end(), + boundString.begin(), ::toupper); + if (boundString != "UPPER" && boundString != "LOWER") throw std::runtime_error( "AGC constraint type should be UPPER or LOWER"); - bound = bound_string == "UPPER" ? Bound::UPPER : Bound::LOWER; - q_lo = params.get("q_lo"); - q_hi = params.get("q_hi"); - Y_target.Read(params.get_child("y_target")); + bound = boundString == "UPPER" ? Bound::UPPER : Bound::LOWER; + qLo = params.get("q_lo"); + qHi = params.get("q_hi"); + yTarget.read(params.get_child("y_target")); } static AgcConstraintMode -read_constraint_mode(boost::property_tree::ptree const ¶ms) +readConstraintMode(boost::property_tree::ptree const ¶ms) { AgcConstraintMode mode; for (auto &p : params) { AgcConstraint constraint; - constraint.Read(p.second); + constraint.read(p.second); mode.push_back(std::move(constraint)); } return mode; } -static std::string read_constraint_modes( - std::map &constraint_modes, - boost::property_tree::ptree const ¶ms) +static std::string readConstraintModes(std::map &constraintModes, + boost::property_tree::ptree const ¶ms) { std::string first; for (auto &p : params) { - constraint_modes[p.first] = read_constraint_mode(p.second); + constraintModes[p.first] = readConstraintMode(p.second); if (first.empty()) first = p.first; } return first; } -void AgcConfig::Read(boost::property_tree::ptree const ¶ms) +void AgcConfig::read(boost::property_tree::ptree const ¶ms) { LOG(RPiAgc, Debug) << "AgcConfig"; - default_metering_mode = read_metering_modes( - metering_modes, params.get_child("metering_modes")); - default_exposure_mode = read_exposure_modes( - exposure_modes, params.get_child("exposure_modes")); - default_constraint_mode = read_constraint_modes( - constraint_modes, params.get_child("constraint_modes")); - Y_target.Read(params.get_child("y_target")); + defaultMeteringMode = readMeteringModes(meteringModes, params.get_child("metering_modes")); + defaultExposureMode = readExposureModes(exposureModes, params.get_child("exposure_modes")); + defaultConstraintMode = readConstraintModes(constraintModes, params.get_child("constraint_modes")); + yTarget.read(params.get_child("y_target")); speed = params.get("speed", 0.2); - startup_frames = params.get("startup_frames", 10); - convergence_frames = params.get("convergence_frames", 6); - fast_reduce_threshold = - params.get("fast_reduce_threshold", 0.4); - base_ev = params.get("base_ev", 1.0); + startupFrames = params.get("startup_frames", 10); + convergenceFrames = params.get("convergence_frames", 6); + fastReduceThreshold = params.get("fast_reduce_threshold", 0.4); + baseEv = params.get("base_ev", 1.0); // Start with quite a low value as ramping up is easier than ramping down. - default_exposure_time = params.get("default_exposure_time", 1000) * 1us; - default_analogue_gain = params.get("default_analogue_gain", 1.0); + defaultExposureTime = params.get("default_exposure_time", 1000) * 1us; + defaultAnalogueGain = params.get("default_analogueGain", 1.0); } Agc::ExposureValues::ExposureValues() - : shutter(0s), analogue_gain(0), - total_exposure(0s), total_exposure_no_dg(0s) + : shutter(0s), analogueGain(0), + totalExposure(0s), totalExposureNoDG(0s) { } Agc::Agc(Controller *controller) - : AgcAlgorithm(controller), metering_mode_(nullptr), - exposure_mode_(nullptr), constraint_mode_(nullptr), - frame_count_(0), lock_count_(0), - last_target_exposure_(0s), last_sensitivity_(0.0), - ev_(1.0), flicker_period_(0s), - max_shutter_(0s), fixed_shutter_(0s), fixed_analogue_gain_(0.0) + : AgcAlgorithm(controller), meteringMode_(nullptr), + exposureMode_(nullptr), constraintMode_(nullptr), + frameCount_(0), lockCount_(0), + lastTargetExposure_(0s), lastSensitivity_(0.0), + ev_(1.0), flickerPeriod_(0s), + maxShutter_(0s), fixedShutter_(0s), fixedAnalogueGain_(0.0) { memset(&awb_, 0, sizeof(awb_)); - // Setting status_.total_exposure_value_ to zero initially tells us + // Setting status_.totalExposureValue_ to zero initially tells us // it's not been calculated yet (i.e. Process hasn't yet run). memset(&status_, 0, sizeof(status_)); status_.ev = ev_; } -char const *Agc::Name() const +char const *Agc::name() const { return NAME; } -void Agc::Read(boost::property_tree::ptree const ¶ms) +void Agc::read(boost::property_tree::ptree const ¶ms) { LOG(RPiAgc, Debug) << "Agc"; - config_.Read(params); + config_.read(params); // Set the config's defaults (which are the first ones it read) as our // current modes, until someone changes them. (they're all known to // exist at this point) - metering_mode_name_ = config_.default_metering_mode; - metering_mode_ = &config_.metering_modes[metering_mode_name_]; - exposure_mode_name_ = config_.default_exposure_mode; - exposure_mode_ = &config_.exposure_modes[exposure_mode_name_]; - constraint_mode_name_ = config_.default_constraint_mode; - constraint_mode_ = &config_.constraint_modes[constraint_mode_name_]; + meteringModeName_ = config_.defaultMeteringMode; + meteringMode_ = &config_.meteringModes[meteringModeName_]; + exposureModeName_ = config_.defaultExposureMode; + exposureMode_ = &config_.exposureModes[exposureModeName_]; + constraintModeName_ = config_.defaultConstraintMode; + constraintMode_ = &config_.constraintModes[constraintModeName_]; // Set up the "last shutter/gain" values, in case AGC starts "disabled". - status_.shutter_time = config_.default_exposure_time; - status_.analogue_gain = config_.default_analogue_gain; + status_.shutterTime = config_.defaultExposureTime; + status_.analogueGain = config_.defaultAnalogueGain; } -bool Agc::IsPaused() const +bool Agc::isPaused() const { return false; } -void Agc::Pause() +void Agc::pause() { - fixed_shutter_ = status_.shutter_time; - fixed_analogue_gain_ = status_.analogue_gain; + fixedShutter_ = status_.shutterTime; + fixedAnalogueGain_ = status_.analogueGain; } -void Agc::Resume() +void Agc::resume() { - fixed_shutter_ = 0s; - fixed_analogue_gain_ = 0; + fixedShutter_ = 0s; + fixedAnalogueGain_ = 0; } -unsigned int Agc::GetConvergenceFrames() const +unsigned int Agc::getConvergenceFrames() const { // If shutter and gain have been explicitly set, there is no // convergence to happen, so no need to drop any frames - return zero. - if (fixed_shutter_ && fixed_analogue_gain_) + if (fixedShutter_ && fixedAnalogueGain_) return 0; else - return config_.convergence_frames; + return config_.convergenceFrames; } -void Agc::SetEv(double ev) +void Agc::setEv(double ev) { ev_ = ev; } -void Agc::SetFlickerPeriod(Duration flicker_period) +void Agc::setFlickerPeriod(Duration flickerPeriod) { - flicker_period_ = flicker_period; + flickerPeriod_ = flickerPeriod; } -void Agc::SetMaxShutter(Duration max_shutter) +void Agc::setMaxShutter(Duration maxShutter) { - max_shutter_ = max_shutter; + maxShutter_ = maxShutter; } -void Agc::SetFixedShutter(Duration fixed_shutter) +void Agc::setFixedShutter(Duration fixedShutter) { - fixed_shutter_ = fixed_shutter; + fixedShutter_ = fixedShutter; // Set this in case someone calls Pause() straight after. - status_.shutter_time = clipShutter(fixed_shutter_); + status_.shutterTime = clipShutter(fixedShutter_); } -void Agc::SetFixedAnalogueGain(double fixed_analogue_gain) +void Agc::setFixedAnalogueGain(double fixedAnalogueGain) { - fixed_analogue_gain_ = fixed_analogue_gain; + fixedAnalogueGain_ = fixedAnalogueGain_; // Set this in case someone calls Pause() straight after. - status_.analogue_gain = fixed_analogue_gain; + status_.analogueGain = fixedAnalogueGain; } -void Agc::SetMeteringMode(std::string const &metering_mode_name) +void Agc::setMeteringMode(std::string const &meteringModeName) { - metering_mode_name_ = metering_mode_name; + meteringModeName_ = meteringModeName; } -void Agc::SetExposureMode(std::string const &exposure_mode_name) +void Agc::setExposureMode(std::string const &exposureModeName) { - exposure_mode_name_ = exposure_mode_name; + exposureModeName_ = exposureModeName; } -void Agc::SetConstraintMode(std::string const &constraint_mode_name) +void Agc::setConstraintMode(std::string const &constraintModeName) { - constraint_mode_name_ = constraint_mode_name; + constraintModeName_ = constraintModeName; } -void Agc::SwitchMode(CameraMode const &camera_mode, +void Agc::switchMode(CameraMode const &cameraMode, Metadata *metadata) { /* AGC expects the mode sensitivity always to be non-zero. */ - ASSERT(camera_mode.sensitivity); + ASSERT(cameraMode.sensitivity); housekeepConfig(); - Duration fixed_shutter = clipShutter(fixed_shutter_); - if (fixed_shutter && fixed_analogue_gain_) { + Duration fixedShutter = clipShutter(fixedShutter_); + if (fixedShutter && fixedAnalogueGain_) { // We're going to reset the algorithm here with these fixed values. fetchAwbStatus(metadata); - double min_colour_gain = std::min({ awb_.gain_r, awb_.gain_g, awb_.gain_b, 1.0 }); - ASSERT(min_colour_gain != 0.0); + double minColourGain = std::min({ awb_.gainR, awb_.gainG, awb_.gainB, 1.0 }); + ASSERT(minColourGain != 0.0); // This is the equivalent of computeTargetExposure and applyDigitalGain. - target_.total_exposure_no_dg = fixed_shutter * fixed_analogue_gain_; - target_.total_exposure = target_.total_exposure_no_dg / min_colour_gain; + target_.totalExposureNoDG = fixedShutter_ * fixedAnalogueGain_; + target_.totalExposure = target_.totalExposureNoDG / minColourGain; // Equivalent of filterExposure. This resets any "history". filtered_ = target_; // Equivalent of divideUpExposure. - filtered_.shutter = fixed_shutter; - filtered_.analogue_gain = fixed_analogue_gain_; - } else if (status_.total_exposure_value) { + filtered_.shutter = fixedShutter; + filtered_.analogueGain = fixedAnalogueGain_; + } else if (status_.totalExposureValue) { // On a mode switch, various things could happen: // - the exposure profile might change // - a fixed exposure or gain might be set @@ -310,11 +305,11 @@ void Agc::SwitchMode(CameraMode const &camera_mode, // that we just need to re-divide the exposure/gain according to the // current exposure profile, which takes care of everything else. - double ratio = last_sensitivity_ / camera_mode.sensitivity; - target_.total_exposure_no_dg *= ratio; - target_.total_exposure *= ratio; - filtered_.total_exposure_no_dg *= ratio; - filtered_.total_exposure *= ratio; + double ratio = lastSensitivity_ / cameraMode.sensitivity; + target_.totalExposureNoDG *= ratio; + target_.totalExposure *= ratio; + filtered_.totalExposureNoDG *= ratio; + filtered_.totalExposure *= ratio; divideUpExposure(); } else { @@ -324,114 +319,110 @@ void Agc::SwitchMode(CameraMode const &camera_mode, // for any that weren't set. // Equivalent of divideUpExposure. - filtered_.shutter = fixed_shutter ? fixed_shutter : config_.default_exposure_time; - filtered_.analogue_gain = fixed_analogue_gain_ ? fixed_analogue_gain_ : config_.default_analogue_gain; + filtered_.shutter = fixedShutter ? fixedShutter : config_.defaultExposureTime; + filtered_.analogueGain = fixedAnalogueGain_ ? fixedAnalogueGain_ : config_.defaultAnalogueGain; } writeAndFinish(metadata, false); // We must remember the sensitivity of this mode for the next SwitchMode. - last_sensitivity_ = camera_mode.sensitivity; + lastSensitivity_ = cameraMode.sensitivity; } -void Agc::Prepare(Metadata *image_metadata) +void Agc::prepare(Metadata *imageMetadata) { - status_.digital_gain = 1.0; - fetchAwbStatus(image_metadata); // always fetch it so that Process knows it's been done + status_.digitalGain = 1.0; + fetchAwbStatus(imageMetadata); // always fetch it so that Process knows it's been done - if (status_.total_exposure_value) { + if (status_.totalExposureValue) { // Process has run, so we have meaningful values. - DeviceStatus device_status; - if (image_metadata->Get("device.status", device_status) == 0) { - Duration actual_exposure = device_status.shutter_speed * - device_status.analogue_gain; - if (actual_exposure) { - status_.digital_gain = - status_.total_exposure_value / - actual_exposure; - LOG(RPiAgc, Debug) << "Want total exposure " << status_.total_exposure_value; + DeviceStatus deviceStatus; + if (imageMetadata->get("device.status", deviceStatus) == 0) { + Duration actualExposure = deviceStatus.shutterSpeed * + deviceStatus.analogueGain; + if (actualExposure) { + status_.digitalGain = status_.totalExposureValue / actualExposure; + LOG(RPiAgc, Debug) << "Want total exposure " << status_.totalExposureValue; // Never ask for a gain < 1.0, and also impose // some upper limit. Make it customisable? - status_.digital_gain = std::max( - 1.0, - std::min(status_.digital_gain, 4.0)); - LOG(RPiAgc, Debug) << "Actual exposure " << actual_exposure; - LOG(RPiAgc, Debug) << "Use digital_gain " << status_.digital_gain; + status_.digitalGain = std::max(1.0, std::min(status_.digitalGain, 4.0)); + LOG(RPiAgc, Debug) << "Actual exposure " << actualExposure; + LOG(RPiAgc, Debug) << "Use digitalGain " << status_.digitalGain; LOG(RPiAgc, Debug) << "Effective exposure " - << actual_exposure * status_.digital_gain; + << actualExposure * status_.digitalGain; // Decide whether AEC/AGC has converged. - updateLockStatus(device_status); + updateLockStatus(deviceStatus); } } else - LOG(RPiAgc, Warning) << Name() << ": no device metadata"; - image_metadata->Set("agc.status", status_); + LOG(RPiAgc, Warning) << name() << ": no device metadata"; + imageMetadata->set("agc.status", status_); } } -void Agc::Process(StatisticsPtr &stats, Metadata *image_metadata) +void Agc::process(StatisticsPtr &stats, Metadata *imageMetadata) { - frame_count_++; + frameCount_++; // First a little bit of housekeeping, fetching up-to-date settings and // configuration, that kind of thing. housekeepConfig(); // Get the current exposure values for the frame that's just arrived. - fetchCurrentExposure(image_metadata); + fetchCurrentExposure(imageMetadata); // Compute the total gain we require relative to the current exposure. - double gain, target_Y; - computeGain(stats.get(), image_metadata, gain, target_Y); + double gain, targetY; + computeGain(stats.get(), imageMetadata, gain, targetY); // Now compute the target (final) exposure which we think we want. computeTargetExposure(gain); // Some of the exposure has to be applied as digital gain, so work out // what that is. This function also tells us whether it's decided to // "desaturate" the image more quickly. - bool desaturate = applyDigitalGain(gain, target_Y); + bool desaturate = applyDigitalGain(gain, targetY); // The results have to be filtered so as not to change too rapidly. filterExposure(desaturate); // The last thing is to divide up the exposure value into a shutter time - // and analogue_gain, according to the current exposure mode. + // and analogue gain, according to the current exposure mode. divideUpExposure(); // Finally advertise what we've done. - writeAndFinish(image_metadata, desaturate); + writeAndFinish(imageMetadata, desaturate); } -void Agc::updateLockStatus(DeviceStatus const &device_status) +void Agc::updateLockStatus(DeviceStatus const &deviceStatus) { - const double ERROR_FACTOR = 0.10; // make these customisable? - const int MAX_LOCK_COUNT = 5; - // Reset "lock count" when we exceed this multiple of ERROR_FACTOR - const double RESET_MARGIN = 1.5; + const double errorFactor = 0.10; // make these customisable? + const int maxLockCount = 5; + // Reset "lock count" when we exceed this multiple of errorFactor + const double resetMargin = 1.5; // Add 200us to the exposure time error to allow for line quantisation. - Duration exposure_error = last_device_status_.shutter_speed * ERROR_FACTOR + 200us; - double gain_error = last_device_status_.analogue_gain * ERROR_FACTOR; - Duration target_error = last_target_exposure_ * ERROR_FACTOR; + Duration exposureError = lastDeviceStatus_.shutterSpeed * errorFactor + 200us; + double gainError = lastDeviceStatus_.analogueGain * errorFactor; + Duration targetError = lastTargetExposure_ * errorFactor; // Note that we don't know the exposure/gain limits of the sensor, so // the values we keep requesting may be unachievable. For this reason // we only insist that we're close to values in the past few frames. - if (device_status.shutter_speed > last_device_status_.shutter_speed - exposure_error && - device_status.shutter_speed < last_device_status_.shutter_speed + exposure_error && - device_status.analogue_gain > last_device_status_.analogue_gain - gain_error && - device_status.analogue_gain < last_device_status_.analogue_gain + gain_error && - status_.target_exposure_value > last_target_exposure_ - target_error && - status_.target_exposure_value < last_target_exposure_ + target_error) - lock_count_ = std::min(lock_count_ + 1, MAX_LOCK_COUNT); - else if (device_status.shutter_speed < last_device_status_.shutter_speed - RESET_MARGIN * exposure_error || - device_status.shutter_speed > last_device_status_.shutter_speed + RESET_MARGIN * exposure_error || - device_status.analogue_gain < last_device_status_.analogue_gain - RESET_MARGIN * gain_error || - device_status.analogue_gain > last_device_status_.analogue_gain + RESET_MARGIN * gain_error || - status_.target_exposure_value < last_target_exposure_ - RESET_MARGIN * target_error || - status_.target_exposure_value > last_target_exposure_ + RESET_MARGIN * target_error) - lock_count_ = 0; - - last_device_status_ = device_status; - last_target_exposure_ = status_.target_exposure_value; - - LOG(RPiAgc, Debug) << "Lock count updated to " << lock_count_; - status_.locked = lock_count_ == MAX_LOCK_COUNT; -} - -static void copy_string(std::string const &s, char *d, size_t size) + if (deviceStatus.shutterSpeed > lastDeviceStatus_.shutterSpeed - exposureError && + deviceStatus.shutterSpeed < lastDeviceStatus_.shutterSpeed + exposureError && + deviceStatus.analogueGain > lastDeviceStatus_.analogueGain - gainError && + deviceStatus.analogueGain < lastDeviceStatus_.analogueGain + gainError && + status_.targetExposureValue > lastTargetExposure_ - targetError && + status_.targetExposureValue < lastTargetExposure_ + targetError) + lockCount_ = std::min(lockCount_ + 1, maxLockCount); + else if (deviceStatus.shutterSpeed < lastDeviceStatus_.shutterSpeed - resetMargin * exposureError || + deviceStatus.shutterSpeed > lastDeviceStatus_.shutterSpeed + resetMargin * exposureError || + deviceStatus.analogueGain < lastDeviceStatus_.analogueGain - resetMargin * gainError || + deviceStatus.analogueGain > lastDeviceStatus_.analogueGain + resetMargin * gainError || + status_.targetExposureValue < lastTargetExposure_ - resetMargin * targetError || + status_.targetExposureValue > lastTargetExposure_ + resetMargin * targetError) + lockCount_ = 0; + + lastDeviceStatus_ = deviceStatus; + lastTargetExposure_ = status_.targetExposureValue; + + LOG(RPiAgc, Debug) << "Lock count updated to " << lockCount_; + status_.locked = lockCount_ == maxLockCount; +} + +static void copyString(std::string const &s, char *d, size_t size) { size_t length = s.copy(d, size - 1); d[length] = '\0'; @@ -441,97 +432,97 @@ void Agc::housekeepConfig() { // First fetch all the up-to-date settings, so no one else has to do it. status_.ev = ev_; - status_.fixed_shutter = clipShutter(fixed_shutter_); - status_.fixed_analogue_gain = fixed_analogue_gain_; - status_.flicker_period = flicker_period_; - LOG(RPiAgc, Debug) << "ev " << status_.ev << " fixed_shutter " - << status_.fixed_shutter << " fixed_analogue_gain " - << status_.fixed_analogue_gain; + status_.fixedShutter = clipShutter(fixedShutter_); + status_.fixedAnalogueGain = fixedAnalogueGain_; + status_.flickerPeriod = flickerPeriod_; + LOG(RPiAgc, Debug) << "ev " << status_.ev << " fixedShutter " + << status_.fixedShutter << " fixedAnalogueGain " + << status_.fixedAnalogueGain; // Make sure the "mode" pointers point to the up-to-date things, if // they've changed. - if (strcmp(metering_mode_name_.c_str(), status_.metering_mode)) { - auto it = config_.metering_modes.find(metering_mode_name_); - if (it == config_.metering_modes.end()) + if (strcmp(meteringModeName_.c_str(), status_.meteringMode)) { + auto it = config_.meteringModes.find(meteringModeName_); + if (it == config_.meteringModes.end()) throw std::runtime_error("Agc: no metering mode " + - metering_mode_name_); - metering_mode_ = &it->second; - copy_string(metering_mode_name_, status_.metering_mode, - sizeof(status_.metering_mode)); + meteringModeName_); + meteringMode_ = &it->second; + copyString(meteringModeName_, status_.meteringMode, + sizeof(status_.meteringMode)); } - if (strcmp(exposure_mode_name_.c_str(), status_.exposure_mode)) { - auto it = config_.exposure_modes.find(exposure_mode_name_); - if (it == config_.exposure_modes.end()) + if (strcmp(exposureModeName_.c_str(), status_.exposureMode)) { + auto it = config_.exposureModes.find(exposureModeName_); + if (it == config_.exposureModes.end()) throw std::runtime_error("Agc: no exposure profile " + - exposure_mode_name_); - exposure_mode_ = &it->second; - copy_string(exposure_mode_name_, status_.exposure_mode, - sizeof(status_.exposure_mode)); + exposureModeName_); + exposureMode_ = &it->second; + copyString(exposureModeName_, status_.exposureMode, + sizeof(status_.exposureMode)); } - if (strcmp(constraint_mode_name_.c_str(), status_.constraint_mode)) { + if (strcmp(constraintModeName_.c_str(), status_.constraintMode)) { auto it = - config_.constraint_modes.find(constraint_mode_name_); - if (it == config_.constraint_modes.end()) + config_.constraintModes.find(constraintModeName_); + if (it == config_.constraintModes.end()) throw std::runtime_error("Agc: no constraint list " + - constraint_mode_name_); - constraint_mode_ = &it->second; - copy_string(constraint_mode_name_, status_.constraint_mode, - sizeof(status_.constraint_mode)); + constraintModeName_); + constraintMode_ = &it->second; + copyString(constraintModeName_, status_.constraintMode, + sizeof(status_.constraintMode)); } - LOG(RPiAgc, Debug) << "exposure_mode " - << exposure_mode_name_ << " constraint_mode " - << constraint_mode_name_ << " metering_mode " - << metering_mode_name_; + LOG(RPiAgc, Debug) << "exposureMode " + << exposureModeName_ << " constraintMode " + << constraintModeName_ << " meteringMode " + << meteringModeName_; } -void Agc::fetchCurrentExposure(Metadata *image_metadata) +void Agc::fetchCurrentExposure(Metadata *imageMetadata) { - std::unique_lock lock(*image_metadata); - DeviceStatus *device_status = - image_metadata->GetLocked("device.status"); - if (!device_status) + std::unique_lock lock(*imageMetadata); + DeviceStatus *deviceStatus = + imageMetadata->getLocked("device.status"); + if (!deviceStatus) throw std::runtime_error("Agc: no device metadata"); - current_.shutter = device_status->shutter_speed; - current_.analogue_gain = device_status->analogue_gain; - AgcStatus *agc_status = - image_metadata->GetLocked("agc.status"); - current_.total_exposure = agc_status ? agc_status->total_exposure_value : 0s; - current_.total_exposure_no_dg = current_.shutter * current_.analogue_gain; + current_.shutter = deviceStatus->shutterSpeed; + current_.analogueGain = deviceStatus->analogueGain; + AgcStatus *agcStatus = + imageMetadata->getLocked("agc.status"); + current_.totalExposure = agcStatus ? agcStatus->totalExposureValue : 0s; + current_.totalExposureNoDG = current_.shutter * current_.analogueGain; } -void Agc::fetchAwbStatus(Metadata *image_metadata) +void Agc::fetchAwbStatus(Metadata *imageMetadata) { - awb_.gain_r = 1.0; // in case not found in metadata - awb_.gain_g = 1.0; - awb_.gain_b = 1.0; - if (image_metadata->Get("awb.status", awb_) != 0) + awb_.gainR = 1.0; // in case not found in metadata + awb_.gainG = 1.0; + awb_.gainB = 1.0; + if (imageMetadata->get("awb.status", awb_) != 0) LOG(RPiAgc, Debug) << "Agc: no AWB status found"; } -static double compute_initial_Y(bcm2835_isp_stats *stats, AwbStatus const &awb, - double weights[], double gain) +static double computeInitialY(bcm2835_isp_stats *stats, AwbStatus const &awb, + double weights[], double gain) { bcm2835_isp_stats_region *regions = stats->agc_stats; // Note how the calculation below means that equal weights give you // "average" metering (i.e. all pixels equally important). - double R_sum = 0, G_sum = 0, B_sum = 0, pixel_sum = 0; + double rSum = 0, gSum = 0, bSum = 0, pixelSum = 0; for (int i = 0; i < AGC_STATS_SIZE; i++) { double counted = regions[i].counted; - double r_sum = std::min(regions[i].r_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted); - double g_sum = std::min(regions[i].g_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted); - double b_sum = std::min(regions[i].b_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted); - R_sum += r_sum * weights[i]; - G_sum += g_sum * weights[i]; - B_sum += b_sum * weights[i]; - pixel_sum += counted * weights[i]; + double rAcc = std::min(regions[i].r_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted); + double gAcc = std::min(regions[i].g_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted); + double bAcc = std::min(regions[i].b_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted); + rSum += rAcc * weights[i]; + gSum += gAcc * weights[i]; + bSum += bAcc * weights[i]; + pixelSum += counted * weights[i]; } - if (pixel_sum == 0.0) { - LOG(RPiAgc, Warning) << "compute_initial_Y: pixel_sum is zero"; + if (pixelSum == 0.0) { + LOG(RPiAgc, Warning) << "computeInitialY: pixel_sum is zero"; return 0; } - double Y_sum = R_sum * awb.gain_r * .299 + - G_sum * awb.gain_g * .587 + - B_sum * awb.gain_b * .114; - return Y_sum / pixel_sum / (1 << PIPELINE_BITS); + double ySum = rSum * awb.gainR * .299 + + gSum * awb.gainG * .587 + + bSum * awb.gainB * .114; + return ySum / pixelSum / (1 << PIPELINE_BITS); } // We handle extra gain through EV by adjusting our Y targets. However, you @@ -542,108 +533,102 @@ static double compute_initial_Y(bcm2835_isp_stats *stats, AwbStatus const &awb, #define EV_GAIN_Y_TARGET_LIMIT 0.9 -static double constraint_compute_gain(AgcConstraint &c, Histogram &h, - double lux, double ev_gain, - double &target_Y) +static double constraintComputeGain(AgcConstraint &c, Histogram &h, double lux, + double evGain, double &targetY) { - target_Y = c.Y_target.Eval(c.Y_target.Domain().Clip(lux)); - target_Y = std::min(EV_GAIN_Y_TARGET_LIMIT, target_Y * ev_gain); - double iqm = h.InterQuantileMean(c.q_lo, c.q_hi); - return (target_Y * NUM_HISTOGRAM_BINS) / iqm; + targetY = c.yTarget.eval(c.yTarget.domain().clip(lux)); + targetY = std::min(EV_GAIN_Y_TARGET_LIMIT, targetY * evGain); + double iqm = h.interQuantileMean(c.qLo, c.qHi); + return (targetY * NUM_HISTOGRAM_BINS) / iqm; } -void Agc::computeGain(bcm2835_isp_stats *statistics, Metadata *image_metadata, - double &gain, double &target_Y) +void Agc::computeGain(bcm2835_isp_stats *statistics, Metadata *imageMetadata, + double &gain, double &targetY) { struct LuxStatus lux = {}; lux.lux = 400; // default lux level to 400 in case no metadata found - if (image_metadata->Get("lux.status", lux) != 0) + if (imageMetadata->get("lux.status", lux) != 0) LOG(RPiAgc, Warning) << "Agc: no lux level found"; Histogram h(statistics->hist[0].g_hist, NUM_HISTOGRAM_BINS); - double ev_gain = status_.ev * config_.base_ev; + double evGain = status_.ev * config_.baseEv; // The initial gain and target_Y come from some of the regions. After // that we consider the histogram constraints. - target_Y = - config_.Y_target.Eval(config_.Y_target.Domain().Clip(lux.lux)); - target_Y = std::min(EV_GAIN_Y_TARGET_LIMIT, target_Y * ev_gain); + targetY = config_.yTarget.eval(config_.yTarget.domain().clip(lux.lux)); + targetY = std::min(EV_GAIN_Y_TARGET_LIMIT, targetY * evGain); // Do this calculation a few times as brightness increase can be // non-linear when there are saturated regions. gain = 1.0; for (int i = 0; i < 8; i++) { - double initial_Y = compute_initial_Y(statistics, awb_, - metering_mode_->weights, gain); - double extra_gain = std::min(10.0, target_Y / (initial_Y + .001)); - gain *= extra_gain; - LOG(RPiAgc, Debug) << "Initial Y " << initial_Y << " target " << target_Y + double initialY = computeInitialY(statistics, awb_, meteringMode_->weights, gain); + double extraGain = std::min(10.0, targetY / (initialY + .001)); + gain *= extraGain; + LOG(RPiAgc, Debug) << "Initial Y " << initialY << " target " << targetY << " gives gain " << gain; - if (extra_gain < 1.01) // close enough + if (extraGain < 1.01) // close enough break; } - for (auto &c : *constraint_mode_) { - double new_target_Y; - double new_gain = - constraint_compute_gain(c, h, lux.lux, ev_gain, - new_target_Y); + for (auto &c : *constraintMode_) { + double newTargetY; + double newGain = constraintComputeGain(c, h, lux.lux, evGain, newTargetY); LOG(RPiAgc, Debug) << "Constraint has target_Y " - << new_target_Y << " giving gain " << new_gain; - if (c.bound == AgcConstraint::Bound::LOWER && - new_gain > gain) { + << newTargetY << " giving gain " << newGain; + if (c.bound == AgcConstraint::Bound::LOWER && newGain > gain) { LOG(RPiAgc, Debug) << "Lower bound constraint adopted"; - gain = new_gain, target_Y = new_target_Y; - } else if (c.bound == AgcConstraint::Bound::UPPER && - new_gain < gain) { + gain = newGain; + targetY = newTargetY; + } else if (c.bound == AgcConstraint::Bound::UPPER && newGain < gain) { LOG(RPiAgc, Debug) << "Upper bound constraint adopted"; - gain = new_gain, target_Y = new_target_Y; + gain = newGain; + targetY = newTargetY; } } - LOG(RPiAgc, Debug) << "Final gain " << gain << " (target_Y " << target_Y << " ev " - << status_.ev << " base_ev " << config_.base_ev + LOG(RPiAgc, Debug) << "Final gain " << gain << " (target_Y " << targetY << " ev " + << status_.ev << " base_ev " << config_.baseEv << ")"; } void Agc::computeTargetExposure(double gain) { - if (status_.fixed_shutter && status_.fixed_analogue_gain) { + if (status_.fixedShutter && status_.fixedAnalogueGain) { // When ag and shutter are both fixed, we need to drive the // total exposure so that we end up with a digital gain of at least - // 1/min_colour_gain. Otherwise we'd desaturate channels causing + // 1/minColourGain. Otherwise we'd desaturate channels causing // white to go cyan or magenta. - double min_colour_gain = std::min({ awb_.gain_r, awb_.gain_g, awb_.gain_b, 1.0 }); - ASSERT(min_colour_gain != 0.0); - target_.total_exposure = - status_.fixed_shutter * status_.fixed_analogue_gain / min_colour_gain; + double minColourGain = std::min({ awb_.gainR, awb_.gainG, awb_.gainB, 1.0 }); + ASSERT(minColourGain != 0.0); + target_.totalExposure = + status_.fixedShutter * status_.fixedAnalogueGain / minColourGain; } else { // The statistics reflect the image without digital gain, so the final // total exposure we're aiming for is: - target_.total_exposure = current_.total_exposure_no_dg * gain; + target_.totalExposure = current_.totalExposureNoDG * gain; // The final target exposure is also limited to what the exposure // mode allows. - Duration max_shutter = status_.fixed_shutter - ? status_.fixed_shutter - : exposure_mode_->shutter.back(); - max_shutter = clipShutter(max_shutter); - Duration max_total_exposure = - max_shutter * - (status_.fixed_analogue_gain != 0.0 - ? status_.fixed_analogue_gain - : exposure_mode_->gain.back()); - target_.total_exposure = std::min(target_.total_exposure, - max_total_exposure); + Duration maxShutter = status_.fixedShutter + ? status_.fixedShutter + : exposureMode_->shutter.back(); + maxShutter = clipShutter(maxShutter); + Duration maxTotalExposure = + maxShutter * + (status_.fixedAnalogueGain != 0.0 + ? status_.fixedAnalogueGain + : exposureMode_->gain.back()); + target_.totalExposure = std::min(target_.totalExposure, maxTotalExposure); } - LOG(RPiAgc, Debug) << "Target total_exposure " << target_.total_exposure; + LOG(RPiAgc, Debug) << "Target totalExposure " << target_.totalExposure; } -bool Agc::applyDigitalGain(double gain, double target_Y) +bool Agc::applyDigitalGain(double gain, double targetY) { - double min_colour_gain = std::min({ awb_.gain_r, awb_.gain_g, awb_.gain_b, 1.0 }); - ASSERT(min_colour_gain != 0.0); - double dg = 1.0 / min_colour_gain; + double minColourGain = std::min({ awb_.gainR, awb_.gainG, awb_.gainB, 1.0 }); + ASSERT(minColourGain != 0.0); + double dg = 1.0 / minColourGain; // I think this pipeline subtracts black level and rescales before we // get the stats, so no need to worry about it. LOG(RPiAgc, Debug) << "after AWB, target dg " << dg << " gain " << gain - << " target_Y " << target_Y; + << " target_Y " << targetY; // Finally, if we're trying to reduce exposure but the target_Y is // "close" to 1.0, then the gain computed for that constraint will be // only slightly less than one, because the measured Y can never be @@ -651,13 +636,13 @@ bool Agc::applyDigitalGain(double gain, double target_Y) // that the exposure can be reduced, de-saturating the image much more // quickly (and we then approach the correct value more quickly from // below). - bool desaturate = target_Y > config_.fast_reduce_threshold && - gain < sqrt(target_Y); + bool desaturate = targetY > config_.fastReduceThreshold && + gain < sqrt(targetY); if (desaturate) - dg /= config_.fast_reduce_threshold; + dg /= config_.fastReduceThreshold; LOG(RPiAgc, Debug) << "Digital gain " << dg << " desaturate? " << desaturate; - target_.total_exposure_no_dg = target_.total_exposure / dg; - LOG(RPiAgc, Debug) << "Target total_exposure_no_dg " << target_.total_exposure_no_dg; + target_.totalExposureNoDG = target_.totalExposure / dg; + LOG(RPiAgc, Debug) << "Target totalExposureNoDG " << target_.totalExposureNoDG; return desaturate; } @@ -666,39 +651,38 @@ void Agc::filterExposure(bool desaturate) double speed = config_.speed; // AGC adapts instantly if both shutter and gain are directly specified // or we're in the startup phase. - if ((status_.fixed_shutter && status_.fixed_analogue_gain) || - frame_count_ <= config_.startup_frames) + if ((status_.fixedShutter && status_.fixedAnalogueGain) || + frameCount_ <= config_.startupFrames) speed = 1.0; - if (!filtered_.total_exposure) { - filtered_.total_exposure = target_.total_exposure; - filtered_.total_exposure_no_dg = target_.total_exposure_no_dg; + if (!filtered_.totalExposure) { + filtered_.totalExposure = target_.totalExposure; + filtered_.totalExposureNoDG = target_.totalExposureNoDG; } else { // If close to the result go faster, to save making so many // micro-adjustments on the way. (Make this customisable?) - if (filtered_.total_exposure < 1.2 * target_.total_exposure && - filtered_.total_exposure > 0.8 * target_.total_exposure) + if (filtered_.totalExposure < 1.2 * target_.totalExposure && + filtered_.totalExposure > 0.8 * target_.totalExposure) speed = sqrt(speed); - filtered_.total_exposure = speed * target_.total_exposure + - filtered_.total_exposure * (1.0 - speed); - // When desaturing, take a big jump down in exposure_no_dg, + filtered_.totalExposure = speed * target_.totalExposure + + filtered_.totalExposure * (1.0 - speed); + // When desaturing, take a big jump down in totalExposureNoDG, // which we'll hide with digital gain. if (desaturate) - filtered_.total_exposure_no_dg = - target_.total_exposure_no_dg; + filtered_.totalExposureNoDG = + target_.totalExposureNoDG; else - filtered_.total_exposure_no_dg = - speed * target_.total_exposure_no_dg + - filtered_.total_exposure_no_dg * (1.0 - speed); + filtered_.totalExposureNoDG = + speed * target_.totalExposureNoDG + + filtered_.totalExposureNoDG * (1.0 - speed); } - // We can't let the no_dg exposure deviate too far below the + // We can't let the totalExposureNoDG exposure deviate too far below the // total exposure, as there might not be enough digital gain available // in the ISP to hide it (which will cause nasty oscillation). - if (filtered_.total_exposure_no_dg < - filtered_.total_exposure * config_.fast_reduce_threshold) - filtered_.total_exposure_no_dg = filtered_.total_exposure * - config_.fast_reduce_threshold; - LOG(RPiAgc, Debug) << "After filtering, total_exposure " << filtered_.total_exposure - << " no dg " << filtered_.total_exposure_no_dg; + if (filtered_.totalExposureNoDG < + filtered_.totalExposure * config_.fastReduceThreshold) + filtered_.totalExposureNoDG = filtered_.totalExposure * config_.fastReduceThreshold; + LOG(RPiAgc, Debug) << "After filtering, totalExposure " << filtered_.totalExposure + << " no dg " << filtered_.totalExposureNoDG; } void Agc::divideUpExposure() @@ -706,92 +690,84 @@ void Agc::divideUpExposure() // Sending the fixed shutter/gain cases through the same code may seem // unnecessary, but it will make more sense when extend this to cover // variable aperture. - Duration exposure_value = filtered_.total_exposure_no_dg; - Duration shutter_time; - double analogue_gain; - shutter_time = status_.fixed_shutter - ? status_.fixed_shutter - : exposure_mode_->shutter[0]; - shutter_time = clipShutter(shutter_time); - analogue_gain = status_.fixed_analogue_gain != 0.0 - ? status_.fixed_analogue_gain - : exposure_mode_->gain[0]; - if (shutter_time * analogue_gain < exposure_value) { + Duration exposureValue = filtered_.totalExposureNoDG; + Duration shutterTime; + double analogueGain; + shutterTime = status_.fixedShutter ? status_.fixedShutter + : exposureMode_->shutter[0]; + shutterTime = clipShutter(shutterTime); + analogueGain = status_.fixedAnalogueGain != 0.0 ? status_.fixedAnalogueGain + : exposureMode_->gain[0]; + if (shutterTime * analogueGain < exposureValue) { for (unsigned int stage = 1; - stage < exposure_mode_->gain.size(); stage++) { - if (!status_.fixed_shutter) { - Duration stage_shutter = - clipShutter(exposure_mode_->shutter[stage]); - if (stage_shutter * analogue_gain >= - exposure_value) { - shutter_time = - exposure_value / analogue_gain; + stage < exposureMode_->gain.size(); stage++) { + if (!status_.fixedShutter) { + Duration stageShutter = + clipShutter(exposureMode_->shutter[stage]); + if (stageShutter * analogueGain >= exposureValue) { + shutterTime = exposureValue / analogueGain; break; } - shutter_time = stage_shutter; + shutterTime = stageShutter; } - if (status_.fixed_analogue_gain == 0.0) { - if (exposure_mode_->gain[stage] * - shutter_time >= - exposure_value) { - analogue_gain = - exposure_value / shutter_time; + if (status_.fixedAnalogueGain == 0.0) { + if (exposureMode_->gain[stage] * shutterTime >= exposureValue) { + analogueGain = exposureValue / shutterTime; break; } - analogue_gain = exposure_mode_->gain[stage]; + analogueGain = exposureMode_->gain[stage]; } } } - LOG(RPiAgc, Debug) << "Divided up shutter and gain are " << shutter_time << " and " - << analogue_gain; + LOG(RPiAgc, Debug) << "Divided up shutter and gain are " << shutterTime << " and " + << analogueGain; // Finally adjust shutter time for flicker avoidance (require both // shutter and gain not to be fixed). - if (!status_.fixed_shutter && !status_.fixed_analogue_gain && - status_.flicker_period) { - int flicker_periods = shutter_time / status_.flicker_period; - if (flicker_periods) { - Duration new_shutter_time = flicker_periods * status_.flicker_period; - analogue_gain *= shutter_time / new_shutter_time; + if (!status_.fixedShutter && !status_.fixedAnalogueGain && + status_.flickerPeriod) { + int flickerPeriods = shutterTime / status_.flickerPeriod; + if (flickerPeriods) { + Duration newShutterTime = flickerPeriods * status_.flickerPeriod; + analogueGain *= shutterTime / newShutterTime; // We should still not allow the ag to go over the // largest value in the exposure mode. Note that this // may force more of the total exposure into the digital // gain as a side-effect. - analogue_gain = std::min(analogue_gain, - exposure_mode_->gain.back()); - shutter_time = new_shutter_time; + analogueGain = std::min(analogueGain, exposureMode_->gain.back()); + shutterTime = newShutterTime; } LOG(RPiAgc, Debug) << "After flicker avoidance, shutter " - << shutter_time << " gain " << analogue_gain; + << shutterTime << " gain " << analogueGain; } - filtered_.shutter = shutter_time; - filtered_.analogue_gain = analogue_gain; + filtered_.shutter = shutterTime; + filtered_.analogueGain = analogueGain; } -void Agc::writeAndFinish(Metadata *image_metadata, bool desaturate) +void Agc::writeAndFinish(Metadata *imageMetadata, bool desaturate) { - status_.total_exposure_value = filtered_.total_exposure; - status_.target_exposure_value = desaturate ? 0s : target_.total_exposure_no_dg; - status_.shutter_time = filtered_.shutter; - status_.analogue_gain = filtered_.analogue_gain; + status_.totalExposureValue = filtered_.totalExposure; + status_.targetExposureValue = desaturate ? 0s : target_.totalExposureNoDG; + status_.shutterTime = filtered_.shutter; + status_.analogueGain = filtered_.analogueGain; // Write to metadata as well, in case anyone wants to update the camera // immediately. - image_metadata->Set("agc.status", status_); + imageMetadata->set("agc.status", status_); LOG(RPiAgc, Debug) << "Output written, total exposure requested is " - << filtered_.total_exposure; + << filtered_.totalExposure; LOG(RPiAgc, Debug) << "Camera exposure update: shutter time " << filtered_.shutter - << " analogue gain " << filtered_.analogue_gain; + << " analogue gain " << filtered_.analogueGain; } Duration Agc::clipShutter(Duration shutter) { - if (max_shutter_) - shutter = std::min(shutter, max_shutter_); + if (maxShutter_) + shutter = std::min(shutter, maxShutter_); return shutter; } // Register algorithm with the system. -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return (Algorithm *)new Agc(controller); } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/agc.hpp b/src/ipa/raspberrypi/controller/rpi/agc.hpp index c100d3128c90..4ed7293bce97 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.hpp @@ -26,114 +26,114 @@ namespace RPiController { struct AgcMeteringMode { double weights[AGC_STATS_SIZE]; - void Read(boost::property_tree::ptree const ¶ms); + void read(boost::property_tree::ptree const ¶ms); }; struct AgcExposureMode { std::vector shutter; std::vector gain; - void Read(boost::property_tree::ptree const ¶ms); + void read(boost::property_tree::ptree const ¶ms); }; struct AgcConstraint { enum class Bound { LOWER = 0, UPPER = 1 }; Bound bound; - double q_lo; - double q_hi; - Pwl Y_target; - void Read(boost::property_tree::ptree const ¶ms); + double qLo; + double qHi; + Pwl yTarget; + void read(boost::property_tree::ptree const ¶ms); }; typedef std::vector AgcConstraintMode; struct AgcConfig { - void Read(boost::property_tree::ptree const ¶ms); - std::map metering_modes; - std::map exposure_modes; - std::map constraint_modes; - Pwl Y_target; + void read(boost::property_tree::ptree const ¶ms); + std::map meteringModes; + std::map exposureModes; + std::map constraintModes; + Pwl yTarget; double speed; - uint16_t startup_frames; - unsigned int convergence_frames; - double max_change; - double min_change; - double fast_reduce_threshold; - double speed_up_threshold; - std::string default_metering_mode; - std::string default_exposure_mode; - std::string default_constraint_mode; - double base_ev; - libcamera::utils::Duration default_exposure_time; - double default_analogue_gain; + uint16_t startupFrames; + unsigned int convergenceFrames; + double maxChange; + double minChange; + double fastReduceThreshold; + double speedUpThreshold; + std::string defaultMeteringMode; + std::string defaultExposureMode; + std::string defaultConstraintMode; + double baseEv; + libcamera::utils::Duration defaultExposureTime; + double defaultAnalogueGain; }; class Agc : public AgcAlgorithm { public: Agc(Controller *controller); - char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; + char const *name() const override; + void read(boost::property_tree::ptree const ¶ms) override; // AGC handles "pausing" for itself. - bool IsPaused() const override; - void Pause() override; - void Resume() override; - unsigned int GetConvergenceFrames() const override; - void SetEv(double ev) override; - void SetFlickerPeriod(libcamera::utils::Duration flicker_period) override; - void SetMaxShutter(libcamera::utils::Duration max_shutter) override; - void SetFixedShutter(libcamera::utils::Duration fixed_shutter) override; - void SetFixedAnalogueGain(double fixed_analogue_gain) override; - void SetMeteringMode(std::string const &metering_mode_name) override; - void SetExposureMode(std::string const &exposure_mode_name) override; - void SetConstraintMode(std::string const &contraint_mode_name) override; - void SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override; - void Prepare(Metadata *image_metadata) override; - void Process(StatisticsPtr &stats, Metadata *image_metadata) override; + bool isPaused() const override; + void pause() override; + void resume() override; + unsigned int getConvergenceFrames() const override; + void setEv(double ev) override; + void setFlickerPeriod(libcamera::utils::Duration flickerPeriod) override; + void setMaxShutter(libcamera::utils::Duration maxShutter) override; + void setFixedShutter(libcamera::utils::Duration fixedShutter) override; + void setFixedAnalogueGain(double fixedAnalogueGain) override; + void setMeteringMode(std::string const &meteringModeName) override; + void setExposureMode(std::string const &exposureModeName) override; + void setConstraintMode(std::string const &contraintModeName) override; + void switchMode(CameraMode const &cameraMode, Metadata *metadata) override; + void prepare(Metadata *imageMetadata) override; + void process(StatisticsPtr &stats, Metadata *imageMetadata) override; private: - void updateLockStatus(DeviceStatus const &device_status); + void updateLockStatus(DeviceStatus const &deviceStatus); AgcConfig config_; void housekeepConfig(); - void fetchCurrentExposure(Metadata *image_metadata); - void fetchAwbStatus(Metadata *image_metadata); - void computeGain(bcm2835_isp_stats *statistics, Metadata *image_metadata, - double &gain, double &target_Y); + void fetchCurrentExposure(Metadata *imageMetadata); + void fetchAwbStatus(Metadata *imageMetadata); + void computeGain(bcm2835_isp_stats *statistics, Metadata *imageMetadata, + double &gain, double &targetY); void computeTargetExposure(double gain); - bool applyDigitalGain(double gain, double target_Y); + bool applyDigitalGain(double gain, double targetY); void filterExposure(bool desaturate); void divideUpExposure(); - void writeAndFinish(Metadata *image_metadata, bool desaturate); + void writeAndFinish(Metadata *imageMetadata, bool desaturate); libcamera::utils::Duration clipShutter(libcamera::utils::Duration shutter); - AgcMeteringMode *metering_mode_; - AgcExposureMode *exposure_mode_; - AgcConstraintMode *constraint_mode_; - uint64_t frame_count_; + AgcMeteringMode *meteringMode_; + AgcExposureMode *exposureMode_; + AgcConstraintMode *constraintMode_; + uint64_t frameCount_; AwbStatus awb_; struct ExposureValues { ExposureValues(); libcamera::utils::Duration shutter; - double analogue_gain; - libcamera::utils::Duration total_exposure; - libcamera::utils::Duration total_exposure_no_dg; // without digital gain + double analogueGain; + libcamera::utils::Duration totalExposure; + libcamera::utils::Duration totalExposureNoDG; // without digital gain }; ExposureValues current_; // values for the current frame ExposureValues target_; // calculate the values we want here ExposureValues filtered_; // these values are filtered towards target AgcStatus status_; - int lock_count_; - DeviceStatus last_device_status_; - libcamera::utils::Duration last_target_exposure_; - double last_sensitivity_; // sensitivity of the previous camera mode + int lockCount_; + DeviceStatus lastDeviceStatus_; + libcamera::utils::Duration lastTargetExposure_; + double lastSensitivity_; // sensitivity of the previous camera mode // Below here the "settings" that applications can change. - std::string metering_mode_name_; - std::string exposure_mode_name_; - std::string constraint_mode_name_; + std::string meteringModeName_; + std::string exposureModeName_; + std::string constraintModeName_; double ev_; - libcamera::utils::Duration flicker_period_; - libcamera::utils::Duration max_shutter_; - libcamera::utils::Duration fixed_shutter_; - double fixed_analogue_gain_; + libcamera::utils::Duration flickerPeriod_; + libcamera::utils::Duration maxShutter_; + libcamera::utils::Duration fixedShutter_; + double fixedAnalogueGain_; }; } // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp index e575c14a92db..98b771542d95 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp @@ -26,31 +26,31 @@ LOG_DEFINE_CATEGORY(RPiAlsc) static const int X = ALSC_CELLS_X; static const int Y = ALSC_CELLS_Y; static const int XY = X * Y; -static const double INSUFFICIENT_DATA = -1.0; +static const double InsufficientData = -1.0; Alsc::Alsc(Controller *controller) : Algorithm(controller) { - async_abort_ = async_start_ = async_started_ = async_finished_ = false; - async_thread_ = std::thread(std::bind(&Alsc::asyncFunc, this)); + asyncAbort_ = asyncStart_ = asyncStarted_ = asyncFinished_ = false; + asyncThread_ = std::thread(std::bind(&Alsc::asyncFunc, this)); } Alsc::~Alsc() { { std::lock_guard lock(mutex_); - async_abort_ = true; + asyncAbort_ = true; } - async_signal_.notify_one(); - async_thread_.join(); + asyncSignal_.notify_one(); + asyncThread_.join(); } -char const *Alsc::Name() const +char const *Alsc::name() const { return NAME; } -static void generate_lut(double *lut, boost::property_tree::ptree const ¶ms) +static void generateLut(double *lut, boost::property_tree::ptree const ¶ms) { double cstrength = params.get("corner_strength", 2.0); if (cstrength <= 1.0) @@ -73,34 +73,34 @@ static void generate_lut(double *lut, boost::property_tree::ptree const ¶ms) } } -static void read_lut(double *lut, boost::property_tree::ptree const ¶ms) +static void readLut(double *lut, boost::property_tree::ptree const ¶ms) { int num = 0; - const int max_num = XY; + const int maxNum = XY; for (auto &p : params) { - if (num == max_num) + if (num == maxNum) throw std::runtime_error( "Alsc: too many entries in LSC table"); lut[num++] = p.second.get_value(); } - if (num < max_num) + if (num < maxNum) throw std::runtime_error("Alsc: too few entries in LSC table"); } -static void read_calibrations(std::vector &calibrations, - boost::property_tree::ptree const ¶ms, - std::string const &name) +static void readCalibrations(std::vector &calibrations, + boost::property_tree::ptree const ¶ms, + std::string const &name) { if (params.get_child_optional(name)) { - double last_ct = 0; + double lastCt = 0; for (auto &p : params.get_child(name)) { double ct = p.second.get("ct"); - if (ct <= last_ct) + if (ct <= lastCt) throw std::runtime_error( "Alsc: entries in " + name + " must be in increasing ct order"); AlscCalibration calibration; - calibration.ct = last_ct = ct; + calibration.ct = lastCt = ct; boost::property_tree::ptree const &table = p.second.get_child("table"); int num = 0; @@ -124,249 +124,239 @@ static void read_calibrations(std::vector &calibrations, } } -void Alsc::Read(boost::property_tree::ptree const ¶ms) +void Alsc::read(boost::property_tree::ptree const ¶ms) { - config_.frame_period = params.get("frame_period", 12); - config_.startup_frames = params.get("startup_frames", 10); + config_.framePeriod = params.get("frame_period", 12); + config_.startupFrames = params.get("startup_frames", 10); config_.speed = params.get("speed", 0.05); double sigma = params.get("sigma", 0.01); - config_.sigma_Cr = params.get("sigma_Cr", sigma); - config_.sigma_Cb = params.get("sigma_Cb", sigma); - config_.min_count = params.get("min_count", 10.0); - config_.min_G = params.get("min_G", 50); + config_.sigmaCr = params.get("sigma_Cr", sigma); + config_.sigmaCb = params.get("sigma_Cb", sigma); + config_.minCount = params.get("min_count", 10.0); + config_.minG = params.get("min_G", 50); config_.omega = params.get("omega", 1.3); - config_.n_iter = params.get("n_iter", X + Y); - config_.luminance_strength = + config_.nIter = params.get("n_iter", X + Y); + config_.luminanceStrength = params.get("luminance_strength", 1.0); for (int i = 0; i < XY; i++) - config_.luminance_lut[i] = 1.0; + config_.luminanceLut[i] = 1.0; if (params.get_child_optional("corner_strength")) - generate_lut(config_.luminance_lut, params); + generateLut(config_.luminanceLut, params); else if (params.get_child_optional("luminance_lut")) - read_lut(config_.luminance_lut, - params.get_child("luminance_lut")); + readLut(config_.luminanceLut, + params.get_child("luminance_lut")); else LOG(RPiAlsc, Warning) << "no luminance table - assume unity everywhere"; - read_calibrations(config_.calibrations_Cr, params, "calibrations_Cr"); - read_calibrations(config_.calibrations_Cb, params, "calibrations_Cb"); - config_.default_ct = params.get("default_ct", 4500.0); + readCalibrations(config_.calibrationsCr, params, "calibrations_Cr"); + readCalibrations(config_.calibrationsCb, params, "calibrations_Cb"); + config_.defaultCt = params.get("default_ct", 4500.0); config_.threshold = params.get("threshold", 1e-3); - config_.lambda_bound = params.get("lambda_bound", 0.05); -} - -static double get_ct(Metadata *metadata, double default_ct); -static void get_cal_table(double ct, - std::vector const &calibrations, - double cal_table[XY]); -static void resample_cal_table(double const cal_table_in[XY], - CameraMode const &camera_mode, - double cal_table_out[XY]); -static void compensate_lambdas_for_cal(double const cal_table[XY], - double const old_lambdas[XY], - double new_lambdas[XY]); -static void add_luminance_to_tables(double results[3][Y][X], - double const lambda_r[XY], double lambda_g, - double const lambda_b[XY], - double const luminance_lut[XY], - double luminance_strength); - -void Alsc::Initialise() -{ - frame_count2_ = frame_count_ = frame_phase_ = 0; - first_time_ = true; - ct_ = config_.default_ct; + config_.lambdaBound = params.get("lambda_bound", 0.05); +} + +static double getCt(Metadata *metadata, double defaultCt); +static void getCalTable(double ct, std::vector const &calibrations, + double calTable[XY]); +static void resampleCalTable(double const calTableIn[XY], CameraMode const &cameraMode, + double calTableOut[XY]); +static void compensateLambdasForCal(double const calTable[XY], double const oldLambdas[XY], + double newLambdas[XY]); +static void addLuminanceToTables(double results[3][Y][X], double const lambdaR[XY], double lambdaG, + double const lambdaB[XY], double const luminanceLut[XY], + double luminanceStrength); + +void Alsc::initialise() +{ + frameCount2_ = frameCount_ = framePhase_ = 0; + firstTime_ = true; + ct_ = config_.defaultCt; // The lambdas are initialised in the SwitchMode. } void Alsc::waitForAysncThread() { - if (async_started_) { - async_started_ = false; + if (asyncStarted_) { + asyncStarted_ = false; std::unique_lock lock(mutex_); - sync_signal_.wait(lock, [&] { - return async_finished_; + syncSignal_.wait(lock, [&] { + return asyncFinished_; }); - async_finished_ = false; + asyncFinished_ = false; } } -static bool compare_modes(CameraMode const &cm0, CameraMode const &cm1) +static bool compareModes(CameraMode const &cm0, CameraMode const &cm1) { // Return true if the modes crop from the sensor significantly differently, // or if the user transform has changed. if (cm0.transform != cm1.transform) return true; - int left_diff = abs(cm0.crop_x - cm1.crop_x); - int top_diff = abs(cm0.crop_y - cm1.crop_y); - int right_diff = fabs(cm0.crop_x + cm0.scale_x * cm0.width - - cm1.crop_x - cm1.scale_x * cm1.width); - int bottom_diff = fabs(cm0.crop_y + cm0.scale_y * cm0.height - - cm1.crop_y - cm1.scale_y * cm1.height); + int leftDiff = abs(cm0.cropX - cm1.cropX); + int topDiff = abs(cm0.cropY - cm1.cropY); + int rightDiff = fabs(cm0.cropX + cm0.scaleX * cm0.width - + cm1.cropX - cm1.scaleX * cm1.width); + int bottomDiff = fabs(cm0.cropY + cm0.scaleY * cm0.height - + cm1.cropY - cm1.scaleY * cm1.height); // These thresholds are a rather arbitrary amount chosen to trigger // when carrying on with the previously calculated tables might be // worse than regenerating them (but without the adaptive algorithm). - int threshold_x = cm0.sensor_width >> 4; - int threshold_y = cm0.sensor_height >> 4; - return left_diff > threshold_x || right_diff > threshold_x || - top_diff > threshold_y || bottom_diff > threshold_y; + int thresholdX = cm0.sensorWidth >> 4; + int thresholdY = cm0.sensorHeight >> 4; + return leftDiff > thresholdX || rightDiff > thresholdX || + topDiff > thresholdY || bottomDiff > thresholdY; } -void Alsc::SwitchMode(CameraMode const &camera_mode, +void Alsc::switchMode(CameraMode const &cameraMode, [[maybe_unused]] Metadata *metadata) { // We're going to start over with the tables if there's any "significant" // change. - bool reset_tables = first_time_ || compare_modes(camera_mode_, camera_mode); + bool resetTables = firstTime_ || compareModes(cameraMode_, cameraMode); // Believe the colour temperature from the AWB, if there is one. - ct_ = get_ct(metadata, ct_); + ct_ = getCt(metadata, ct_); // Ensure the other thread isn't running while we do this. waitForAysncThread(); - camera_mode_ = camera_mode; + cameraMode_ = cameraMode; // We must resample the luminance table like we do the others, but it's // fixed so we can simply do it up front here. - resample_cal_table(config_.luminance_lut, camera_mode_, luminance_table_); + resampleCalTable(config_.luminanceLut, cameraMode_, luminanceTable_); - if (reset_tables) { + if (resetTables) { // Upon every "table reset", arrange for something sensible to be // generated. Construct the tables for the previous recorded colour // temperature. In order to start over from scratch we initialise // the lambdas, but the rest of this code then echoes the code in // doAlsc, without the adaptive algorithm. for (int i = 0; i < XY; i++) - lambda_r_[i] = lambda_b_[i] = 1.0; - double cal_table_r[XY], cal_table_b[XY], cal_table_tmp[XY]; - get_cal_table(ct_, config_.calibrations_Cr, cal_table_tmp); - resample_cal_table(cal_table_tmp, camera_mode_, cal_table_r); - get_cal_table(ct_, config_.calibrations_Cb, cal_table_tmp); - resample_cal_table(cal_table_tmp, camera_mode_, cal_table_b); - compensate_lambdas_for_cal(cal_table_r, lambda_r_, - async_lambda_r_); - compensate_lambdas_for_cal(cal_table_b, lambda_b_, - async_lambda_b_); - add_luminance_to_tables(sync_results_, async_lambda_r_, 1.0, - async_lambda_b_, luminance_table_, - config_.luminance_strength); - memcpy(prev_sync_results_, sync_results_, - sizeof(prev_sync_results_)); - frame_phase_ = config_.frame_period; // run the algo again asap - first_time_ = false; + lambdaR_[i] = lambdaB_[i] = 1.0; + double calTableR[XY], calTableB[XY], calTableTmp[XY]; + getCalTable(ct_, config_.calibrationsCr, calTableTmp); + resampleCalTable(calTableTmp, cameraMode_, calTableR); + getCalTable(ct_, config_.calibrationsCb, calTableTmp); + resampleCalTable(calTableTmp, cameraMode_, calTableB); + compensateLambdasForCal(calTableR, lambdaR_, asyncLambdaR_); + compensateLambdasForCal(calTableB, lambdaB_, asyncLambdaB_); + addLuminanceToTables(syncResults_, asyncLambdaR_, 1.0, asyncLambdaB_, + luminanceTable_, config_.luminanceStrength); + memcpy(prevSyncResults_, syncResults_, sizeof(prevSyncResults_)); + framePhase_ = config_.framePeriod; // run the algo again asap + firstTime_ = false; } } void Alsc::fetchAsyncResults() { LOG(RPiAlsc, Debug) << "Fetch ALSC results"; - async_finished_ = false; - async_started_ = false; - memcpy(sync_results_, async_results_, sizeof(sync_results_)); + asyncFinished_ = false; + asyncStarted_ = false; + memcpy(syncResults_, asyncResults_, sizeof(syncResults_)); } -double get_ct(Metadata *metadata, double default_ct) +double getCt(Metadata *metadata, double defaultCt) { - AwbStatus awb_status; - awb_status.temperature_K = default_ct; // in case nothing found - if (metadata->Get("awb.status", awb_status) != 0) + AwbStatus awbStatus; + awbStatus.temperatureK = defaultCt; // in case nothing found + if (metadata->get("awb.status", awbStatus) != 0) LOG(RPiAlsc, Debug) << "no AWB results found, using " - << awb_status.temperature_K; + << awbStatus.temperatureK; else LOG(RPiAlsc, Debug) << "AWB results found, using " - << awb_status.temperature_K; - return awb_status.temperature_K; + << awbStatus.temperatureK; + return awbStatus.temperatureK; } -static void copy_stats(bcm2835_isp_stats_region regions[XY], StatisticsPtr &stats, - AlscStatus const &status) +static void copyStats(bcm2835_isp_stats_region regions[XY], StatisticsPtr &stats, + AlscStatus const &status) { - bcm2835_isp_stats_region *input_regions = stats->awb_stats; - double *r_table = (double *)status.r; - double *g_table = (double *)status.g; - double *b_table = (double *)status.b; + bcm2835_isp_stats_region *inputRegions = stats->awb_stats; + double *rTable = (double *)status.r; + double *gTable = (double *)status.g; + double *bTable = (double *)status.b; for (int i = 0; i < XY; i++) { - regions[i].r_sum = input_regions[i].r_sum / r_table[i]; - regions[i].g_sum = input_regions[i].g_sum / g_table[i]; - regions[i].b_sum = input_regions[i].b_sum / b_table[i]; - regions[i].counted = input_regions[i].counted; + regions[i].r_sum = inputRegions[i].r_sum / rTable[i]; + regions[i].g_sum = inputRegions[i].g_sum / gTable[i]; + regions[i].b_sum = inputRegions[i].b_sum / bTable[i]; + regions[i].counted = inputRegions[i].counted; // (don't care about the uncounted value) } } -void Alsc::restartAsync(StatisticsPtr &stats, Metadata *image_metadata) +void Alsc::restartAsync(StatisticsPtr &stats, Metadata *imageMetadata) { LOG(RPiAlsc, Debug) << "Starting ALSC calculation"; // Get the current colour temperature. It's all we need from the // metadata. Default to the last CT value (which could be the default). - ct_ = get_ct(image_metadata, ct_); + ct_ = getCt(imageMetadata, ct_); // We have to copy the statistics here, dividing out our best guess of // the LSC table that the pipeline applied to them. - AlscStatus alsc_status; - if (image_metadata->Get("alsc.status", alsc_status) != 0) { + AlscStatus alscStatus; + if (imageMetadata->get("alsc.status", alscStatus) != 0) { LOG(RPiAlsc, Warning) << "No ALSC status found for applied gains!"; for (int y = 0; y < Y; y++) for (int x = 0; x < X; x++) { - alsc_status.r[y][x] = 1.0; - alsc_status.g[y][x] = 1.0; - alsc_status.b[y][x] = 1.0; + alscStatus.r[y][x] = 1.0; + alscStatus.g[y][x] = 1.0; + alscStatus.b[y][x] = 1.0; } } - copy_stats(statistics_, stats, alsc_status); - frame_phase_ = 0; - async_started_ = true; + copyStats(statistics_, stats, alscStatus); + framePhase_ = 0; + asyncStarted_ = true; { std::lock_guard lock(mutex_); - async_start_ = true; + asyncStart_ = true; } - async_signal_.notify_one(); + asyncSignal_.notify_one(); } -void Alsc::Prepare(Metadata *image_metadata) +void Alsc::prepare(Metadata *imageMetadata) { // Count frames since we started, and since we last poked the async // thread. - if (frame_count_ < (int)config_.startup_frames) - frame_count_++; - double speed = frame_count_ < (int)config_.startup_frames + if (frameCount_ < (int)config_.startupFrames) + frameCount_++; + double speed = frameCount_ < (int)config_.startupFrames ? 1.0 : config_.speed; LOG(RPiAlsc, Debug) - << "frame_count " << frame_count_ << " speed " << speed; + << "frame count " << frameCount_ << " speed " << speed; { std::unique_lock lock(mutex_); - if (async_started_ && async_finished_) + if (asyncStarted_ && asyncFinished_) fetchAsyncResults(); } // Apply IIR filter to results and program into the pipeline. - double *ptr = (double *)sync_results_, - *pptr = (double *)prev_sync_results_; - for (unsigned int i = 0; - i < sizeof(sync_results_) / sizeof(double); i++) + double *ptr = (double *)syncResults_, + *pptr = (double *)prevSyncResults_; + for (unsigned int i = 0; i < sizeof(syncResults_) / sizeof(double); i++) pptr[i] = speed * ptr[i] + (1.0 - speed) * pptr[i]; // Put output values into status metadata. AlscStatus status; - memcpy(status.r, prev_sync_results_[0], sizeof(status.r)); - memcpy(status.g, prev_sync_results_[1], sizeof(status.g)); - memcpy(status.b, prev_sync_results_[2], sizeof(status.b)); - image_metadata->Set("alsc.status", status); + memcpy(status.r, prevSyncResults_[0], sizeof(status.r)); + memcpy(status.g, prevSyncResults_[1], sizeof(status.g)); + memcpy(status.b, prevSyncResults_[2], sizeof(status.b)); + imageMetadata->set("alsc.status", status); } -void Alsc::Process(StatisticsPtr &stats, Metadata *image_metadata) +void Alsc::process(StatisticsPtr &stats, Metadata *imageMetadata) { // Count frames since we started, and since we last poked the async // thread. - if (frame_phase_ < (int)config_.frame_period) - frame_phase_++; - if (frame_count2_ < (int)config_.startup_frames) - frame_count2_++; - LOG(RPiAlsc, Debug) << "frame_phase " << frame_phase_; - if (frame_phase_ >= (int)config_.frame_period || - frame_count2_ < (int)config_.startup_frames) { - if (async_started_ == false) - restartAsync(stats, image_metadata); + if (framePhase_ < (int)config_.framePeriod) + framePhase_++; + if (frameCount2_ < (int)config_.startupFrames) + frameCount2_++; + LOG(RPiAlsc, Debug) << "frame_phase " << framePhase_; + if (framePhase_ >= (int)config_.framePeriod || + frameCount2_ < (int)config_.startupFrames) { + if (asyncStarted_ == false) + restartAsync(stats, imageMetadata); } } @@ -375,143 +365,140 @@ void Alsc::asyncFunc() while (true) { { std::unique_lock lock(mutex_); - async_signal_.wait(lock, [&] { - return async_start_ || async_abort_; + asyncSignal_.wait(lock, [&] { + return asyncStart_ || asyncAbort_; }); - async_start_ = false; - if (async_abort_) + asyncStart_ = false; + if (asyncAbort_) break; } doAlsc(); { std::lock_guard lock(mutex_); - async_finished_ = true; + asyncFinished_ = true; } - sync_signal_.notify_one(); + syncSignal_.notify_one(); } } -void get_cal_table(double ct, std::vector const &calibrations, - double cal_table[XY]) +void getCalTable(double ct, std::vector const &calibrations, + double calTable[XY]) { if (calibrations.empty()) { for (int i = 0; i < XY; i++) - cal_table[i] = 1.0; + calTable[i] = 1.0; LOG(RPiAlsc, Debug) << "no calibrations found"; } else if (ct <= calibrations.front().ct) { - memcpy(cal_table, calibrations.front().table, - XY * sizeof(double)); + memcpy(calTable, calibrations.front().table, XY * sizeof(double)); LOG(RPiAlsc, Debug) << "using calibration for " << calibrations.front().ct; } else if (ct >= calibrations.back().ct) { - memcpy(cal_table, calibrations.back().table, - XY * sizeof(double)); + memcpy(calTable, calibrations.back().table, XY * sizeof(double)); LOG(RPiAlsc, Debug) << "using calibration for " << calibrations.back().ct; } else { int idx = 0; while (ct > calibrations[idx + 1].ct) idx++; - double ct0 = calibrations[idx].ct, - ct1 = calibrations[idx + 1].ct; + double ct0 = calibrations[idx].ct, ct1 = calibrations[idx + 1].ct; LOG(RPiAlsc, Debug) << "ct is " << ct << ", interpolating between " << ct0 << " and " << ct1; for (int i = 0; i < XY; i++) - cal_table[i] = + calTable[i] = (calibrations[idx].table[i] * (ct1 - ct) + calibrations[idx + 1].table[i] * (ct - ct0)) / (ct1 - ct0); } } -void resample_cal_table(double const cal_table_in[XY], - CameraMode const &camera_mode, double cal_table_out[XY]) +void resampleCalTable(double const calTableIn[XY], + CameraMode const &cameraMode, double calTableOut[XY]) { // Precalculate and cache the x sampling locations and phases to save // recomputing them on every row. - int x_lo[X], x_hi[X]; + int xLo[X], xHi[X]; double xf[X]; - double scale_x = camera_mode.sensor_width / - (camera_mode.width * camera_mode.scale_x); - double x_off = camera_mode.crop_x / (double)camera_mode.sensor_width; - double x = .5 / scale_x + x_off * X - .5; - double x_inc = 1 / scale_x; - for (int i = 0; i < X; i++, x += x_inc) { - x_lo[i] = floor(x); - xf[i] = x - x_lo[i]; - x_hi[i] = std::min(x_lo[i] + 1, X - 1); - x_lo[i] = std::max(x_lo[i], 0); - if (!!(camera_mode.transform & libcamera::Transform::HFlip)) { - x_lo[i] = X - 1 - x_lo[i]; - x_hi[i] = X - 1 - x_hi[i]; + double scaleX = cameraMode.sensorWidth / + (cameraMode.width * cameraMode.scaleX); + double xOff = cameraMode.cropX / (double)cameraMode.sensorWidth; + double x = .5 / scaleX + xOff * X - .5; + double xInc = 1 / scaleX; + for (int i = 0; i < X; i++, x += xInc) { + xLo[i] = floor(x); + xf[i] = x - xLo[i]; + xHi[i] = std::min(xLo[i] + 1, X - 1); + xLo[i] = std::max(xLo[i], 0); + if (!!(cameraMode.transform & libcamera::Transform::HFlip)) { + xLo[i] = X - 1 - xLo[i]; + xHi[i] = X - 1 - xHi[i]; } } // Now march over the output table generating the new values. - double scale_y = camera_mode.sensor_height / - (camera_mode.height * camera_mode.scale_y); - double y_off = camera_mode.crop_y / (double)camera_mode.sensor_height; - double y = .5 / scale_y + y_off * Y - .5; - double y_inc = 1 / scale_y; - for (int j = 0; j < Y; j++, y += y_inc) { - int y_lo = floor(y); - double yf = y - y_lo; - int y_hi = std::min(y_lo + 1, Y - 1); - y_lo = std::max(y_lo, 0); - if (!!(camera_mode.transform & libcamera::Transform::VFlip)) { - y_lo = Y - 1 - y_lo; - y_hi = Y - 1 - y_hi; + double scaleY = cameraMode.sensorHeight / + (cameraMode.height * cameraMode.scaleY); + double yOff = cameraMode.cropY / (double)cameraMode.sensorHeight; + double y = .5 / scaleY + yOff * Y - .5; + double yInc = 1 / scaleY; + for (int j = 0; j < Y; j++, y += yInc) { + int yLo = floor(y); + double yf = y - yLo; + int yHi = std::min(yLo + 1, Y - 1); + yLo = std::max(yLo, 0); + if (!!(cameraMode.transform & libcamera::Transform::VFlip)) { + yLo = Y - 1 - yLo; + yHi = Y - 1 - yHi; } - double const *row_above = cal_table_in + X * y_lo; - double const *row_below = cal_table_in + X * y_hi; + double const *rowAbove = calTableIn + X * yLo; + double const *rowBelow = calTableIn + X * yHi; for (int i = 0; i < X; i++) { - double above = row_above[x_lo[i]] * (1 - xf[i]) + - row_above[x_hi[i]] * xf[i]; - double below = row_below[x_lo[i]] * (1 - xf[i]) + - row_below[x_hi[i]] * xf[i]; - *(cal_table_out++) = above * (1 - yf) + below * yf; + double above = rowAbove[xLo[i]] * (1 - xf[i]) + + rowAbove[xHi[i]] * xf[i]; + double below = rowBelow[xLo[i]] * (1 - xf[i]) + + rowBelow[xHi[i]] * xf[i]; + *(calTableOut++) = above * (1 - yf) + below * yf; } } } // Calculate chrominance statistics (R/G and B/G) for each region. static_assert(XY == AWB_REGIONS, "ALSC/AWB statistics region mismatch"); -static void calculate_Cr_Cb(bcm2835_isp_stats_region *awb_region, double Cr[XY], - double Cb[XY], uint32_t min_count, uint16_t min_G) +static void calculateCrCb(bcm2835_isp_stats_region *awbRegion, double cr[XY], + double cb[XY], uint32_t minCount, uint16_t minG) { for (int i = 0; i < XY; i++) { - bcm2835_isp_stats_region &zone = awb_region[i]; - if (zone.counted <= min_count || - zone.g_sum / zone.counted <= min_G) { - Cr[i] = Cb[i] = INSUFFICIENT_DATA; + bcm2835_isp_stats_region &zone = awbRegion[i]; + if (zone.counted <= minCount || + zone.g_sum / zone.counted <= minG) { + cr[i] = cb[i] = InsufficientData; continue; } - Cr[i] = zone.r_sum / (double)zone.g_sum; - Cb[i] = zone.b_sum / (double)zone.g_sum; + cr[i] = zone.r_sum / (double)zone.g_sum; + cb[i] = zone.b_sum / (double)zone.g_sum; } } -static void apply_cal_table(double const cal_table[XY], double C[XY]) +static void applyCalTable(double const calTable[XY], double C[XY]) { for (int i = 0; i < XY; i++) - if (C[i] != INSUFFICIENT_DATA) - C[i] *= cal_table[i]; + if (C[i] != InsufficientData) + C[i] *= calTable[i]; } -void compensate_lambdas_for_cal(double const cal_table[XY], - double const old_lambdas[XY], - double new_lambdas[XY]) +void compensateLambdasForCal(double const calTable[XY], + double const oldLambdas[XY], + double newLambdas[XY]) { - double min_new_lambda = std::numeric_limits::max(); + double minNewLambda = std::numeric_limits::max(); for (int i = 0; i < XY; i++) { - new_lambdas[i] = old_lambdas[i] * cal_table[i]; - min_new_lambda = std::min(min_new_lambda, new_lambdas[i]); + newLambdas[i] = oldLambdas[i] * calTable[i]; + minNewLambda = std::min(minNewLambda, newLambdas[i]); } for (int i = 0; i < XY; i++) - new_lambdas[i] /= min_new_lambda; + newLambdas[i] /= minNewLambda; } -[[maybe_unused]] static void print_cal_table(double const C[XY]) +[[maybe_unused]] static void printCalTable(double const C[XY]) { printf("table: [\n"); for (int j = 0; j < Y; j++) { @@ -527,31 +514,29 @@ void compensate_lambdas_for_cal(double const cal_table[XY], // Compute weight out of 1.0 which reflects how similar we wish to make the // colours of these two regions. -static double compute_weight(double C_i, double C_j, double sigma) +static double computeWeight(double Ci, double Cj, double sigma) { - if (C_i == INSUFFICIENT_DATA || C_j == INSUFFICIENT_DATA) + if (Ci == InsufficientData || Cj == InsufficientData) return 0; - double diff = (C_i - C_j) / sigma; + double diff = (Ci - Cj) / sigma; return exp(-diff * diff / 2); } // Compute all weights. -static void compute_W(double const C[XY], double sigma, double W[XY][4]) +static void computeW(double const C[XY], double sigma, double W[XY][4]) { for (int i = 0; i < XY; i++) { // Start with neighbour above and go clockwise. - W[i][0] = i >= X ? compute_weight(C[i], C[i - X], sigma) : 0; - W[i][1] = i % X < X - 1 ? compute_weight(C[i], C[i + 1], sigma) - : 0; - W[i][2] = - i < XY - X ? compute_weight(C[i], C[i + X], sigma) : 0; - W[i][3] = i % X ? compute_weight(C[i], C[i - 1], sigma) : 0; + W[i][0] = i >= X ? computeWeight(C[i], C[i - X], sigma) : 0; + W[i][1] = i % X < X - 1 ? computeWeight(C[i], C[i + 1], sigma) : 0; + W[i][2] = i < XY - X ? computeWeight(C[i], C[i + X], sigma) : 0; + W[i][3] = i % X ? computeWeight(C[i], C[i - 1], sigma) : 0; } } // Compute M, the large but sparse matrix such that M * lambdas = 0. -static void construct_M(double const C[XY], double const W[XY][4], - double M[XY][4]) +static void constructM(double const C[XY], double const W[XY][4], + double M[XY][4]) { double epsilon = 0.001; for (int i = 0; i < XY; i++) { @@ -560,108 +545,96 @@ static void construct_M(double const C[XY], double const W[XY][4], int m = !!(i >= X) + !!(i % X < X - 1) + !!(i < XY - X) + !!(i % X); // total number of neighbours // we'll divide the diagonal out straight away - double diagonal = - (epsilon + W[i][0] + W[i][1] + W[i][2] + W[i][3]) * - C[i]; - M[i][0] = i >= X ? (W[i][0] * C[i - X] + epsilon / m * C[i]) / - diagonal - : 0; - M[i][1] = i % X < X - 1 - ? (W[i][1] * C[i + 1] + epsilon / m * C[i]) / - diagonal - : 0; - M[i][2] = i < XY - X - ? (W[i][2] * C[i + X] + epsilon / m * C[i]) / - diagonal - : 0; - M[i][3] = i % X ? (W[i][3] * C[i - 1] + epsilon / m * C[i]) / - diagonal - : 0; + double diagonal = (epsilon + W[i][0] + W[i][1] + W[i][2] + W[i][3]) * C[i]; + M[i][0] = i >= X ? (W[i][0] * C[i - X] + epsilon / m * C[i]) / diagonal : 0; + M[i][1] = i % X < X - 1 ? (W[i][1] * C[i + 1] + epsilon / m * C[i]) / diagonal : 0; + M[i][2] = i < XY - X ? (W[i][2] * C[i + X] + epsilon / m * C[i]) / diagonal : 0; + M[i][3] = i % X ? (W[i][3] * C[i - 1] + epsilon / m * C[i]) / diagonal : 0; } } // In the compute_lambda_ functions, note that the matrix coefficients for the // left/right neighbours are zero down the left/right edges, so we don't need // need to test the i value to exclude them. -static double compute_lambda_bottom(int i, double const M[XY][4], - double lambda[XY]) +static double computeLambdaBottom(int i, double const M[XY][4], + double lambda[XY]) { return M[i][1] * lambda[i + 1] + M[i][2] * lambda[i + X] + M[i][3] * lambda[i - 1]; } -static double compute_lambda_bottom_start(int i, double const M[XY][4], - double lambda[XY]) +static double computeLambdaBottomStart(int i, double const M[XY][4], + double lambda[XY]) { return M[i][1] * lambda[i + 1] + M[i][2] * lambda[i + X]; } -static double compute_lambda_interior(int i, double const M[XY][4], - double lambda[XY]) +static double computeLambdaInterior(int i, double const M[XY][4], + double lambda[XY]) { return M[i][0] * lambda[i - X] + M[i][1] * lambda[i + 1] + M[i][2] * lambda[i + X] + M[i][3] * lambda[i - 1]; } -static double compute_lambda_top(int i, double const M[XY][4], - double lambda[XY]) +static double computeLambdaTop(int i, double const M[XY][4], + double lambda[XY]) { return M[i][0] * lambda[i - X] + M[i][1] * lambda[i + 1] + M[i][3] * lambda[i - 1]; } -static double compute_lambda_top_end(int i, double const M[XY][4], - double lambda[XY]) +static double computeLambdaTopEnd(int i, double const M[XY][4], + double lambda[XY]) { return M[i][0] * lambda[i - X] + M[i][3] * lambda[i - 1]; } // Gauss-Seidel iteration with over-relaxation. -static double gauss_seidel2_SOR(double const M[XY][4], double omega, - double lambda[XY], double lambda_bound) +static double gaussSeidel2Sor(double const M[XY][4], double omega, + double lambda[XY], double lambdaBound) { - const double min = 1 - lambda_bound, max = 1 + lambda_bound; - double old_lambda[XY]; + const double min = 1 - lambdaBound, max = 1 + lambdaBound; + double oldLambda[XY]; int i; for (i = 0; i < XY; i++) - old_lambda[i] = lambda[i]; - lambda[0] = compute_lambda_bottom_start(0, M, lambda); + oldLambda[i] = lambda[i]; + lambda[0] = computeLambdaBottomStart(0, M, lambda); lambda[0] = std::clamp(lambda[0], min, max); for (i = 1; i < X; i++) { - lambda[i] = compute_lambda_bottom(i, M, lambda); + lambda[i] = computeLambdaBottom(i, M, lambda); lambda[i] = std::clamp(lambda[i], min, max); } for (; i < XY - X; i++) { - lambda[i] = compute_lambda_interior(i, M, lambda); + lambda[i] = computeLambdaInterior(i, M, lambda); lambda[i] = std::clamp(lambda[i], min, max); } for (; i < XY - 1; i++) { - lambda[i] = compute_lambda_top(i, M, lambda); + lambda[i] = computeLambdaTop(i, M, lambda); lambda[i] = std::clamp(lambda[i], min, max); } - lambda[i] = compute_lambda_top_end(i, M, lambda); + lambda[i] = computeLambdaTopEnd(i, M, lambda); lambda[i] = std::clamp(lambda[i], min, max); // Also solve the system from bottom to top, to help spread the updates // better. - lambda[i] = compute_lambda_top_end(i, M, lambda); + lambda[i] = computeLambdaTopEnd(i, M, lambda); lambda[i] = std::clamp(lambda[i], min, max); for (i = XY - 2; i >= XY - X; i--) { - lambda[i] = compute_lambda_top(i, M, lambda); + lambda[i] = computeLambdaTop(i, M, lambda); lambda[i] = std::clamp(lambda[i], min, max); } for (; i >= X; i--) { - lambda[i] = compute_lambda_interior(i, M, lambda); + lambda[i] = computeLambdaInterior(i, M, lambda); lambda[i] = std::clamp(lambda[i], min, max); } for (; i >= 1; i--) { - lambda[i] = compute_lambda_bottom(i, M, lambda); + lambda[i] = computeLambdaBottom(i, M, lambda); lambda[i] = std::clamp(lambda[i], min, max); } - lambda[0] = compute_lambda_bottom_start(0, M, lambda); + lambda[0] = computeLambdaBottomStart(0, M, lambda); lambda[0] = std::clamp(lambda[0], min, max); - double max_diff = 0; + double maxDiff = 0; for (i = 0; i < XY; i++) { - lambda[i] = old_lambda[i] + (lambda[i] - old_lambda[i]) * omega; - if (fabs(lambda[i] - old_lambda[i]) > fabs(max_diff)) - max_diff = lambda[i] - old_lambda[i]; + lambda[i] = oldLambda[i] + (lambda[i] - oldLambda[i]) * omega; + if (fabs(lambda[i] - oldLambda[i]) > fabs(maxDiff)) + maxDiff = lambda[i] - oldLambda[i]; } - return max_diff; + return maxDiff; } // Normalise the values so that the smallest value is 1. @@ -683,105 +656,99 @@ static void reaverage(Span data) d *= ratio; } -static void run_matrix_iterations(double const C[XY], double lambda[XY], - double const W[XY][4], double omega, - int n_iter, double threshold, double lambda_bound) +static void runMatrixIterations(double const C[XY], double lambda[XY], + double const W[XY][4], double omega, + int nIter, double threshold, double lambdaBound) { double M[XY][4]; - construct_M(C, W, M); - double last_max_diff = std::numeric_limits::max(); - for (int i = 0; i < n_iter; i++) { - double max_diff = fabs(gauss_seidel2_SOR(M, omega, lambda, lambda_bound)); - if (max_diff < threshold) { + constructM(C, W, M); + double lastMaxDiff = std::numeric_limits::max(); + for (int i = 0; i < nIter; i++) { + double maxDiff = fabs(gaussSeidel2Sor(M, omega, lambda, lambdaBound)); + if (maxDiff < threshold) { LOG(RPiAlsc, Debug) << "Stop after " << i + 1 << " iterations"; break; } // this happens very occasionally (so make a note), though // doesn't seem to matter - if (max_diff > last_max_diff) + if (maxDiff > lastMaxDiff) LOG(RPiAlsc, Debug) - << "Iteration " << i << ": max_diff gone up " - << last_max_diff << " to " << max_diff; - last_max_diff = max_diff; + << "Iteration " << i << ": maxDiff gone up " + << lastMaxDiff << " to " << maxDiff; + lastMaxDiff = maxDiff; } // We're going to normalise the lambdas so the total average is 1. reaverage({ lambda, XY }); } -static void add_luminance_rb(double result[XY], double const lambda[XY], - double const luminance_lut[XY], - double luminance_strength) +static void addLuminanceRb(double result[XY], double const lambda[XY], + double const luminanceLut[XY], + double luminanceStrength) { for (int i = 0; i < XY; i++) - result[i] = lambda[i] * - ((luminance_lut[i] - 1) * luminance_strength + 1); + result[i] = lambda[i] * ((luminanceLut[i] - 1) * luminanceStrength + 1); } -static void add_luminance_g(double result[XY], double lambda, - double const luminance_lut[XY], - double luminance_strength) +static void addLuminanceG(double result[XY], double lambda, + double const luminanceLut[XY], + double luminanceStrength) { for (int i = 0; i < XY; i++) - result[i] = lambda * - ((luminance_lut[i] - 1) * luminance_strength + 1); + result[i] = lambda * ((luminanceLut[i] - 1) * luminanceStrength + 1); } -void add_luminance_to_tables(double results[3][Y][X], double const lambda_r[XY], - double lambda_g, double const lambda_b[XY], - double const luminance_lut[XY], - double luminance_strength) +void addLuminanceToTables(double results[3][Y][X], double const lambdaR[XY], + double lambdaG, double const lambdaB[XY], + double const luminanceLut[XY], + double luminanceStrength) { - add_luminance_rb((double *)results[0], lambda_r, luminance_lut, - luminance_strength); - add_luminance_g((double *)results[1], lambda_g, luminance_lut, - luminance_strength); - add_luminance_rb((double *)results[2], lambda_b, luminance_lut, - luminance_strength); + addLuminanceRb((double *)results[0], lambdaR, luminanceLut, luminanceStrength); + addLuminanceG((double *)results[1], lambdaG, luminanceLut, luminanceStrength); + addLuminanceRb((double *)results[2], lambdaB, luminanceLut, luminanceStrength); normalise((double *)results, 3 * XY); } void Alsc::doAlsc() { - double Cr[XY], Cb[XY], Wr[XY][4], Wb[XY][4], cal_table_r[XY], - cal_table_b[XY], cal_table_tmp[XY]; + double cr[XY], cb[XY], wr[XY][4], wb[XY][4], calTableR[XY], calTableB[XY], calTableTmp[XY]; // Calculate our R/B ("Cr"/"Cb") colour statistics, and assess which are // usable. - calculate_Cr_Cb(statistics_, Cr, Cb, config_.min_count, config_.min_G); + calculateCrCb(statistics_, cr, cb, config_.minCount, config_.minG); // Fetch the new calibrations (if any) for this CT. Resample them in // case the camera mode is not full-frame. - get_cal_table(ct_, config_.calibrations_Cr, cal_table_tmp); - resample_cal_table(cal_table_tmp, camera_mode_, cal_table_r); - get_cal_table(ct_, config_.calibrations_Cb, cal_table_tmp); - resample_cal_table(cal_table_tmp, camera_mode_, cal_table_b); + getCalTable(ct_, config_.calibrationsCr, calTableTmp); + resampleCalTable(calTableTmp, cameraMode_, calTableR); + getCalTable(ct_, config_.calibrationsCb, calTableTmp); + resampleCalTable(calTableTmp, cameraMode_, calTableB); // You could print out the cal tables for this image here, if you're // tuning the algorithm... // Apply any calibration to the statistics, so the adaptive algorithm // makes only the extra adjustments. - apply_cal_table(cal_table_r, Cr); - apply_cal_table(cal_table_b, Cb); + applyCalTable(calTableR, cr); + applyCalTable(calTableB, cb); // Compute weights between zones. - compute_W(Cr, config_.sigma_Cr, Wr); - compute_W(Cb, config_.sigma_Cb, Wb); + computeW(cr, config_.sigmaCr, wr); + computeW(cb, config_.sigmaCb, wb); // Run Gauss-Seidel iterations over the resulting matrix, for R and B. - run_matrix_iterations(Cr, lambda_r_, Wr, config_.omega, config_.n_iter, - config_.threshold, config_.lambda_bound); - run_matrix_iterations(Cb, lambda_b_, Wb, config_.omega, config_.n_iter, - config_.threshold, config_.lambda_bound); + runMatrixIterations(cr, lambdaR_, wr, config_.omega, config_.nIter, + config_.threshold, config_.lambdaBound); + runMatrixIterations(cb, lambdaB_, wb, config_.omega, config_.nIter, + config_.threshold, config_.lambdaBound); // Fold the calibrated gains into our final lambda values. (Note that on // the next run, we re-start with the lambda values that don't have the // calibration gains included.) - compensate_lambdas_for_cal(cal_table_r, lambda_r_, async_lambda_r_); - compensate_lambdas_for_cal(cal_table_b, lambda_b_, async_lambda_b_); + compensateLambdasForCal(calTableR, lambdaR_, asyncLambdaR_); + compensateLambdasForCal(calTableB, lambdaB_, asyncLambdaB_); // Fold in the luminance table at the appropriate strength. - add_luminance_to_tables(async_results_, async_lambda_r_, 1.0, - async_lambda_b_, luminance_table_, - config_.luminance_strength); + addLuminanceToTables(asyncResults_, asyncLambdaR_, 1.0, + asyncLambdaB_, luminanceTable_, + config_.luminanceStrength); } // Register algorithm with the system. -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return (Algorithm *)new Alsc(controller); } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.hpp b/src/ipa/raspberrypi/controller/rpi/alsc.hpp index d1dbe0d1d22d..7a0949d1ccc5 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.hpp @@ -24,24 +24,24 @@ struct AlscCalibration { struct AlscConfig { // Only repeat the ALSC calculation every "this many" frames - uint16_t frame_period; + uint16_t framePeriod; // number of initial frames for which speed taken as 1.0 (maximum) - uint16_t startup_frames; + uint16_t startupFrames; // IIR filter speed applied to algorithm results double speed; - double sigma_Cr; - double sigma_Cb; - double min_count; - uint16_t min_G; + double sigmaCr; + double sigmaCb; + double minCount; + uint16_t minG; double omega; - uint32_t n_iter; - double luminance_lut[ALSC_CELLS_X * ALSC_CELLS_Y]; - double luminance_strength; - std::vector calibrations_Cr; - std::vector calibrations_Cb; - double default_ct; // colour temperature if no metadata found + uint32_t nIter; + double luminanceLut[ALSC_CELLS_X * ALSC_CELLS_Y]; + double luminanceStrength; + std::vector calibrationsCr; + std::vector calibrationsCb; + double defaultCt; // colour temperature if no metadata found double threshold; // iteration termination threshold - double lambda_bound; // upper/lower bound for lambda from a value of 1 + double lambdaBound; // upper/lower bound for lambda from a value of 1 }; class Alsc : public Algorithm @@ -49,58 +49,58 @@ class Alsc : public Algorithm public: Alsc(Controller *controller = NULL); ~Alsc(); - char const *Name() const override; - void Initialise() 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; - void Process(StatisticsPtr &stats, Metadata *image_metadata) override; + char const *name() const override; + void initialise() override; + void switchMode(CameraMode const &cameraMode, Metadata *metadata) override; + void read(boost::property_tree::ptree const ¶ms) override; + void prepare(Metadata *imageMetadata) override; + void process(StatisticsPtr &stats, Metadata *imageMetadata) override; private: // configuration is read-only, and available to both threads AlscConfig config_; - bool first_time_; - CameraMode camera_mode_; - double luminance_table_[ALSC_CELLS_X * ALSC_CELLS_Y]; - std::thread async_thread_; + bool firstTime_; + CameraMode cameraMode_; + double luminanceTable_[ALSC_CELLS_X * ALSC_CELLS_Y]; + std::thread asyncThread_; void asyncFunc(); // asynchronous thread function std::mutex mutex_; // condvar for async thread to wait on - std::condition_variable async_signal_; + std::condition_variable asyncSignal_; // condvar for synchronous thread to wait on - std::condition_variable sync_signal_; + std::condition_variable syncSignal_; // for sync thread to check if async thread finished (requires mutex) - bool async_finished_; + bool asyncFinished_; // for async thread to check if it's been told to run (requires mutex) - bool async_start_; + bool asyncStart_; // for async thread to check if it's been told to quit (requires mutex) - bool async_abort_; + bool asyncAbort_; // The following are only for the synchronous thread to use: // for sync thread to note its has asked async thread to run - bool async_started_; - // counts up to frame_period before restarting the async thread - int frame_phase_; - // counts up to startup_frames - int frame_count_; - // counts up to startup_frames for Process function - int frame_count2_; - double sync_results_[3][ALSC_CELLS_Y][ALSC_CELLS_X]; - double prev_sync_results_[3][ALSC_CELLS_Y][ALSC_CELLS_X]; + bool asyncStarted_; + // counts up to framePeriod before restarting the async thread + int framePhase_; + // counts up to startupFrames + int frameCount_; + // counts up to startupFrames for Process function + int frameCount2_; + double syncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X]; + double prevSyncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X]; void waitForAysncThread(); // The following are for the asynchronous thread to use, though the main // thread can set/reset them if the async thread is known to be idle: - void restartAsync(StatisticsPtr &stats, Metadata *image_metadata); + void restartAsync(StatisticsPtr &stats, Metadata *imageMetadata); // copy out the results from the async thread so that it can be restarted void fetchAsyncResults(); double ct_; bcm2835_isp_stats_region statistics_[ALSC_CELLS_Y * ALSC_CELLS_X]; - double async_results_[3][ALSC_CELLS_Y][ALSC_CELLS_X]; - double async_lambda_r_[ALSC_CELLS_X * ALSC_CELLS_Y]; - double async_lambda_b_[ALSC_CELLS_X * ALSC_CELLS_Y]; + double asyncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X]; + double asyncLambdaR_[ALSC_CELLS_X * ALSC_CELLS_Y]; + double asyncLambdaB_[ALSC_CELLS_X * ALSC_CELLS_Y]; void doAlsc(); - double lambda_r_[ALSC_CELLS_X * ALSC_CELLS_Y]; - double lambda_b_[ALSC_CELLS_X * ALSC_CELLS_Y]; + double lambdaR_[ALSC_CELLS_X * ALSC_CELLS_Y]; + double lambdaB_[ALSC_CELLS_X * ALSC_CELLS_Y]; }; } // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index d4c934473832..a305237f31fb 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp @@ -24,33 +24,33 @@ LOG_DEFINE_CATEGORY(RPiAwb) // todo - the locking in this algorithm needs some tidying up as has been done // elsewhere (ALSC and AGC). -void AwbMode::Read(boost::property_tree::ptree const ¶ms) +void AwbMode::read(boost::property_tree::ptree const ¶ms) { - ct_lo = params.get("lo"); - ct_hi = params.get("hi"); + ctLo = params.get("lo"); + ctHi = params.get("hi"); } -void AwbPrior::Read(boost::property_tree::ptree const ¶ms) +void AwbPrior::read(boost::property_tree::ptree const ¶ms) { lux = params.get("lux"); - prior.Read(params.get_child("prior")); + prior.read(params.get_child("prior")); } -static void read_ct_curve(Pwl &ct_r, Pwl &ct_b, - boost::property_tree::ptree const ¶ms) +static void readCtCurve(Pwl &ctR, Pwl &ctB, + boost::property_tree::ptree const ¶ms) { int num = 0; for (auto it = params.begin(); it != params.end(); it++) { double ct = it->second.get_value(); - assert(it == params.begin() || ct != ct_r.Domain().end); + assert(it == params.begin() || ct != ctR.domain().end); if (++it == params.end()) throw std::runtime_error( "AwbConfig: incomplete CT curve entry"); - ct_r.Append(ct, it->second.get_value()); + ctR.append(ct, it->second.get_value()); if (++it == params.end()) throw std::runtime_error( "AwbConfig: incomplete CT curve entry"); - ct_b.Append(ct, it->second.get_value()); + ctB.append(ct, it->second.get_value()); num++; } if (num < 2) @@ -58,22 +58,21 @@ static void read_ct_curve(Pwl &ct_r, Pwl &ct_b, "AwbConfig: insufficient points in CT curve"); } -void AwbConfig::Read(boost::property_tree::ptree const ¶ms) +void AwbConfig::read(boost::property_tree::ptree const ¶ms) { bayes = params.get("bayes", 1); - frame_period = params.get("frame_period", 10); - startup_frames = params.get("startup_frames", 10); - convergence_frames = params.get("convergence_frames", 3); + framePeriod = params.get("framePeriod", 10); + startupFrames = params.get("startupFrames", 10); + convergenceFrames = params.get("convergence_frames", 3); speed = params.get("speed", 0.05); if (params.get_child_optional("ct_curve")) - read_ct_curve(ct_r, ct_b, params.get_child("ct_curve")); + readCtCurve(ctR, ctB, params.get_child("ct_curve")); if (params.get_child_optional("priors")) { for (auto &p : params.get_child("priors")) { AwbPrior prior; - prior.Read(p.second); + prior.read(p.second); if (!priors.empty() && prior.lux <= priors.back().lux) - throw std::runtime_error( - "AwbConfig: Prior must be ordered in increasing lux value"); + throw std::runtime_error("AwbConfig: Prior must be ordered in increasing lux value"); priors.push_back(prior); } if (priors.empty()) @@ -82,177 +81,170 @@ void AwbConfig::Read(boost::property_tree::ptree const ¶ms) } if (params.get_child_optional("modes")) { for (auto &p : params.get_child("modes")) { - modes[p.first].Read(p.second); - if (default_mode == nullptr) - default_mode = &modes[p.first]; + modes[p.first].read(p.second); + if (defaultMode == nullptr) + defaultMode = &modes[p.first]; } - if (default_mode == nullptr) - throw std::runtime_error( - "AwbConfig: no AWB modes configured"); + if (defaultMode == nullptr) + throw std::runtime_error("AwbConfig: no AWB modes configured"); } - min_pixels = params.get("min_pixels", 16.0); - min_G = params.get("min_G", 32); - min_regions = params.get("min_regions", 10); - delta_limit = params.get("delta_limit", 0.2); - coarse_step = params.get("coarse_step", 0.2); - transverse_pos = params.get("transverse_pos", 0.01); - transverse_neg = params.get("transverse_neg", 0.01); - if (transverse_pos <= 0 || transverse_neg <= 0) - throw std::runtime_error( - "AwbConfig: transverse_pos/neg must be > 0"); - sensitivity_r = params.get("sensitivity_r", 1.0); - sensitivity_b = params.get("sensitivity_b", 1.0); + minPixels = params.get("min_pixels", 16.0); + minG = params.get("min_G", 32); + minRegions = params.get("min_regions", 10); + deltaLimit = params.get("delta_limit", 0.2); + coarseStep = params.get("coarse_step", 0.2); + transversePos = params.get("transverse_pos", 0.01); + transverseNeg = params.get("transverse_neg", 0.01); + if (transversePos <= 0 || transverseNeg <= 0) + throw std::runtime_error("AwbConfig: transverse_pos/neg must be > 0"); + sensitivityR = params.get("sensitivity_r", 1.0); + sensitivityB = params.get("sensitivity_b", 1.0); if (bayes) { - if (ct_r.Empty() || ct_b.Empty() || priors.empty() || - default_mode == nullptr) { + if (ctR.empty() || ctB.empty() || priors.empty() || + defaultMode == nullptr) { LOG(RPiAwb, Warning) << "Bayesian AWB mis-configured - switch to Grey method"; bayes = false; } } - fast = params.get( - "fast", bayes); // default to fast for Bayesian, otherwise slow - whitepoint_r = params.get("whitepoint_r", 0.0); - whitepoint_b = params.get("whitepoint_b", 0.0); + fast = params.get("fast", bayes); // default to fast for Bayesian, otherwise slow + whitepointR = params.get("whitepoint_r", 0.0); + whitepointB = params.get("whitepoint_b", 0.0); if (bayes == false) - sensitivity_r = sensitivity_b = - 1.0; // nor do sensitivities make any sense + sensitivityR = sensitivityB = 1.0; // nor do sensitivities make any sense } Awb::Awb(Controller *controller) : AwbAlgorithm(controller) { - async_abort_ = async_start_ = async_started_ = async_finished_ = false; + asyncAbort_ = asyncStart_ = asyncStarted_ = asyncFinished_ = false; mode_ = nullptr; - manual_r_ = manual_b_ = 0.0; - first_switch_mode_ = true; - async_thread_ = std::thread(std::bind(&Awb::asyncFunc, this)); + manualR_ = manualB_ = 0.0; + firstSwitchMode_ = true; + asyncThread_ = std::thread(std::bind(&Awb::asyncFunc, this)); } Awb::~Awb() { { std::lock_guard lock(mutex_); - async_abort_ = true; + asyncAbort_ = true; } - async_signal_.notify_one(); - async_thread_.join(); + asyncSignal_.notify_one(); + asyncThread_.join(); } -char const *Awb::Name() const +char const *Awb::name() const { return NAME; } -void Awb::Read(boost::property_tree::ptree const ¶ms) +void Awb::read(boost::property_tree::ptree const ¶ms) { - config_.Read(params); + config_.read(params); } -void Awb::Initialise() +void Awb::initialise() { - frame_count_ = frame_phase_ = 0; + frameCount_ = framePhase_ = 0; // Put something sane into the status that we are filtering towards, // just in case the first few frames don't have anything meaningful in // them. - if (!config_.ct_r.Empty() && !config_.ct_b.Empty()) { - sync_results_.temperature_K = config_.ct_r.Domain().Clip(4000); - sync_results_.gain_r = - 1.0 / config_.ct_r.Eval(sync_results_.temperature_K); - sync_results_.gain_g = 1.0; - sync_results_.gain_b = - 1.0 / config_.ct_b.Eval(sync_results_.temperature_K); + if (!config_.ctR.empty() && !config_.ctB.empty()) { + syncResults_.temperatureK = config_.ctR.domain().clip(4000); + syncResults_.gainR = 1.0 / config_.ctR.eval(syncResults_.temperatureK); + syncResults_.gainG = 1.0; + syncResults_.gainB = 1.0 / config_.ctB.eval(syncResults_.temperatureK); } else { // random values just to stop the world blowing up - sync_results_.temperature_K = 4500; - sync_results_.gain_r = sync_results_.gain_g = - sync_results_.gain_b = 1.0; + syncResults_.temperatureK = 4500; + syncResults_.gainR = syncResults_.gainG = syncResults_.gainB = 1.0; } - prev_sync_results_ = sync_results_; - async_results_ = sync_results_; + prevSyncResults_ = syncResults_; + asyncResults_ = syncResults_; } -bool Awb::IsPaused() const +bool Awb::isPaused() const { return false; } -void Awb::Pause() +void Awb::pause() { // "Pause" by fixing everything to the most recent values. - manual_r_ = sync_results_.gain_r = prev_sync_results_.gain_r; - manual_b_ = sync_results_.gain_b = prev_sync_results_.gain_b; - sync_results_.gain_g = prev_sync_results_.gain_g; - sync_results_.temperature_K = prev_sync_results_.temperature_K; + manualR_ = syncResults_.gainR = prevSyncResults_.gainR; + manualB_ = syncResults_.gainB = prevSyncResults_.gainB; + syncResults_.gainG = prevSyncResults_.gainG; + syncResults_.temperatureK = prevSyncResults_.temperatureK; } -void Awb::Resume() +void Awb::resume() { - manual_r_ = 0.0; - manual_b_ = 0.0; + manualR_ = 0.0; + manualB_ = 0.0; } -unsigned int Awb::GetConvergenceFrames() const +unsigned int Awb::getConvergenceFrames() const { // If not in auto mode, there is no convergence // to happen, so no need to drop any frames - return zero. if (!isAutoEnabled()) return 0; else - return config_.convergence_frames; + return config_.convergenceFrames; } -void Awb::SetMode(std::string const &mode_name) +void Awb::setMode(std::string const &modeName) { - mode_name_ = mode_name; + modeName_ = modeName; } -void Awb::SetManualGains(double manual_r, double manual_b) +void Awb::setManualGains(double manualR, double manualB) { // If any of these are 0.0, we swich back to auto. - manual_r_ = manual_r; - manual_b_ = manual_b; - // If not in auto mode, set these values into the sync_results which + manualR_ = manualR; + manualB_ = manualB; + // If not in auto mode, set these values into the syncResults which // means that Prepare() will adopt them immediately. if (!isAutoEnabled()) { - sync_results_.gain_r = prev_sync_results_.gain_r = manual_r_; - sync_results_.gain_g = prev_sync_results_.gain_g = 1.0; - sync_results_.gain_b = prev_sync_results_.gain_b = manual_b_; + syncResults_.gainR = prevSyncResults_.gainR = manualR_; + syncResults_.gainG = prevSyncResults_.gainG = 1.0; + syncResults_.gainB = prevSyncResults_.gainB = manualB_; } } -void Awb::SwitchMode([[maybe_unused]] CameraMode const &camera_mode, +void Awb::switchMode([[maybe_unused]] CameraMode const &cameraMode, Metadata *metadata) { // On the first mode switch we'll have no meaningful colour // temperature, so try to dead reckon one if in manual mode. - if (!isAutoEnabled() && first_switch_mode_ && config_.bayes) { - Pwl ct_r_inverse = config_.ct_r.Inverse(); - Pwl ct_b_inverse = config_.ct_b.Inverse(); - double ct_r = ct_r_inverse.Eval(ct_r_inverse.Domain().Clip(1 / manual_r_)); - double ct_b = ct_b_inverse.Eval(ct_b_inverse.Domain().Clip(1 / manual_b_)); - prev_sync_results_.temperature_K = (ct_r + ct_b) / 2; - sync_results_.temperature_K = prev_sync_results_.temperature_K; + if (!isAutoEnabled() && firstSwitchMode_ && config_.bayes) { + Pwl ctRInverse = config_.ctR.inverse(); + Pwl ctBInverse = config_.ctB.inverse(); + double ctR = ctRInverse.eval(ctRInverse.domain().clip(1 / manualR_)); + double ctB = ctBInverse.eval(ctBInverse.domain().clip(1 / manualB_)); + prevSyncResults_.temperatureK = (ctR + ctB) / 2; + syncResults_.temperatureK = prevSyncResults_.temperatureK; } // Let other algorithms know the current white balance values. - metadata->Set("awb.status", prev_sync_results_); - first_switch_mode_ = false; + metadata->set("awb.status", prevSyncResults_); + firstSwitchMode_ = false; } bool Awb::isAutoEnabled() const { - return manual_r_ == 0.0 || manual_b_ == 0.0; + return manualR_ == 0.0 || manualB_ == 0.0; } void Awb::fetchAsyncResults() { LOG(RPiAwb, Debug) << "Fetch AWB results"; - async_finished_ = false; - async_started_ = false; + asyncFinished_ = false; + asyncStarted_ = false; // It's possible manual gains could be set even while the async // thread was running, so only copy the results if still in auto mode. if (isAutoEnabled()) - sync_results_ = async_results_; + syncResults_ = asyncResults_; } void Awb::restartAsync(StatisticsPtr &stats, double lux) @@ -261,75 +253,74 @@ void Awb::restartAsync(StatisticsPtr &stats, double lux) // this makes a new reference which belongs to the asynchronous thread statistics_ = stats; // store the mode as it could technically change - auto m = config_.modes.find(mode_name_); + auto m = config_.modes.find(modeName_); mode_ = m != config_.modes.end() ? &m->second - : (mode_ == nullptr ? config_.default_mode : mode_); + : (mode_ == nullptr ? config_.defaultMode : mode_); lux_ = lux; - frame_phase_ = 0; - async_started_ = true; - size_t len = mode_name_.copy(async_results_.mode, - sizeof(async_results_.mode) - 1); - async_results_.mode[len] = '\0'; + framePhase_ = 0; + asyncStarted_ = true; + size_t len = modeName_.copy(asyncResults_.mode, + sizeof(asyncResults_.mode) - 1); + asyncResults_.mode[len] = '\0'; { std::lock_guard lock(mutex_); - async_start_ = true; + asyncStart_ = true; } - async_signal_.notify_one(); + asyncSignal_.notify_one(); } -void Awb::Prepare(Metadata *image_metadata) +void Awb::prepare(Metadata *imageMetadata) { - if (frame_count_ < (int)config_.startup_frames) - frame_count_++; - double speed = frame_count_ < (int)config_.startup_frames + if (frameCount_ < (int)config_.startupFrames) + frameCount_++; + double speed = frameCount_ < (int)config_.startupFrames ? 1.0 : config_.speed; LOG(RPiAwb, Debug) - << "frame_count " << frame_count_ << " speed " << speed; + << "frame_count " << frameCount_ << " speed " << speed; { std::unique_lock lock(mutex_); - if (async_started_ && async_finished_) + if (asyncStarted_ && asyncFinished_) fetchAsyncResults(); } // Finally apply IIR filter to results and put into metadata. - memcpy(prev_sync_results_.mode, sync_results_.mode, - sizeof(prev_sync_results_.mode)); - prev_sync_results_.temperature_K = - speed * sync_results_.temperature_K + - (1.0 - speed) * prev_sync_results_.temperature_K; - prev_sync_results_.gain_r = speed * sync_results_.gain_r + - (1.0 - speed) * prev_sync_results_.gain_r; - prev_sync_results_.gain_g = speed * sync_results_.gain_g + - (1.0 - speed) * prev_sync_results_.gain_g; - prev_sync_results_.gain_b = speed * sync_results_.gain_b + - (1.0 - speed) * prev_sync_results_.gain_b; - image_metadata->Set("awb.status", prev_sync_results_); + memcpy(prevSyncResults_.mode, syncResults_.mode, + sizeof(prevSyncResults_.mode)); + prevSyncResults_.temperatureK = speed * syncResults_.temperatureK + + (1.0 - speed) * prevSyncResults_.temperatureK; + prevSyncResults_.gainR = speed * syncResults_.gainR + + (1.0 - speed) * prevSyncResults_.gainR; + prevSyncResults_.gainG = speed * syncResults_.gainG + + (1.0 - speed) * prevSyncResults_.gainG; + prevSyncResults_.gainB = speed * syncResults_.gainB + + (1.0 - speed) * prevSyncResults_.gainB; + imageMetadata->set("awb.status", prevSyncResults_); LOG(RPiAwb, Debug) - << "Using AWB gains r " << prev_sync_results_.gain_r << " g " - << prev_sync_results_.gain_g << " b " - << prev_sync_results_.gain_b; + << "Using AWB gains r " << prevSyncResults_.gainR << " g " + << prevSyncResults_.gainG << " b " + << prevSyncResults_.gainB; } -void Awb::Process(StatisticsPtr &stats, Metadata *image_metadata) +void Awb::process(StatisticsPtr &stats, Metadata *imageMetadata) { // Count frames since we last poked the async thread. - if (frame_phase_ < (int)config_.frame_period) - frame_phase_++; - LOG(RPiAwb, Debug) << "frame_phase " << frame_phase_; + if (framePhase_ < (int)config_.framePeriod) + framePhase_++; + LOG(RPiAwb, Debug) << "frame_phase " << framePhase_; // We do not restart the async thread if we're not in auto mode. if (isAutoEnabled() && - (frame_phase_ >= (int)config_.frame_period || - frame_count_ < (int)config_.startup_frames)) { + (framePhase_ >= (int)config_.framePeriod || + frameCount_ < (int)config_.startupFrames)) { // Update any settings and any image metadata that we need. - struct LuxStatus lux_status = {}; - lux_status.lux = 400; // in case no metadata - if (image_metadata->Get("lux.status", lux_status) != 0) + struct LuxStatus luxStatus = {}; + luxStatus.lux = 400; // in case no metadata + if (imageMetadata->get("lux.status", luxStatus) != 0) LOG(RPiAwb, Debug) << "No lux metadata found"; - LOG(RPiAwb, Debug) << "Awb lux value is " << lux_status.lux; + LOG(RPiAwb, Debug) << "Awb lux value is " << luxStatus.lux; - if (async_started_ == false) - restartAsync(stats, lux_status.lux); + if (asyncStarted_ == false) + restartAsync(stats, luxStatus.lux); } } @@ -338,32 +329,32 @@ void Awb::asyncFunc() while (true) { { std::unique_lock lock(mutex_); - async_signal_.wait(lock, [&] { - return async_start_ || async_abort_; + asyncSignal_.wait(lock, [&] { + return asyncStart_ || asyncAbort_; }); - async_start_ = false; - if (async_abort_) + asyncStart_ = false; + if (asyncAbort_) break; } doAwb(); { std::lock_guard lock(mutex_); - async_finished_ = true; + asyncFinished_ = true; } - sync_signal_.notify_one(); + syncSignal_.notify_one(); } } -static void generate_stats(std::vector &zones, - bcm2835_isp_stats_region *stats, double min_pixels, - double min_G) +static void generateStats(std::vector &zones, + bcm2835_isp_stats_region *stats, double minPixels, + double minG) { for (int i = 0; i < AWB_STATS_SIZE_X * AWB_STATS_SIZE_Y; i++) { Awb::RGB zone; double counted = stats[i].counted; - if (counted >= min_pixels) { + if (counted >= minPixels) { zone.G = stats[i].g_sum / counted; - if (zone.G >= min_G) { + if (zone.G >= minG) { zone.R = stats[i].r_sum / counted; zone.B = stats[i].b_sum / counted; zones.push_back(zone); @@ -377,32 +368,33 @@ void Awb::prepareStats() zones_.clear(); // LSC has already been applied to the stats in this pipeline, so stop // any LSC compensation. We also ignore config_.fast in this version. - generate_stats(zones_, statistics_->awb_stats, config_.min_pixels, - config_.min_G); + generateStats(zones_, statistics_->awb_stats, config_.minPixels, + config_.minG); // we're done with these; we may as well relinquish our hold on the // pointer. statistics_.reset(); // apply sensitivities, so values appear to come from our "canonical" // sensor. - for (auto &zone : zones_) - zone.R *= config_.sensitivity_r, - zone.B *= config_.sensitivity_b; + for (auto &zone : zones_) { + zone.R *= config_.sensitivityR; + zone.B *= config_.sensitivityB; + } } -double Awb::computeDelta2Sum(double gain_r, double gain_b) +double Awb::computeDelta2Sum(double gainR, double gainB) { // Compute the sum of the squared colour error (non-greyness) as it // appears in the log likelihood equation. - double delta2_sum = 0; + double delta2Sum = 0; for (auto &z : zones_) { - double delta_r = gain_r * z.R - 1 - config_.whitepoint_r; - double delta_b = gain_b * z.B - 1 - config_.whitepoint_b; - double delta2 = delta_r * delta_r + delta_b * delta_b; + double deltaR = gainR * z.R - 1 - config_.whitepointR; + double deltaB = gainB * z.B - 1 - config_.whitepointB; + double delta2 = deltaR * deltaR + deltaB * deltaB; //LOG(RPiAwb, Debug) << "delta_r " << delta_r << " delta_b " << delta_b << " delta2 " << delta2; - delta2 = std::min(delta2, config_.delta_limit); - delta2_sum += delta2; + delta2 = std::min(delta2, config_.deltaLimit); + delta2Sum += delta2; } - return delta2_sum; + return delta2Sum; } Pwl Awb::interpolatePrior() @@ -420,7 +412,7 @@ Pwl Awb::interpolatePrior() idx++; double lux0 = config_.priors[idx].lux, lux1 = config_.priors[idx + 1].lux; - return Pwl::Combine(config_.priors[idx].prior, + return Pwl::combine(config_.priors[idx].prior, config_.priors[idx + 1].prior, [&](double /*x*/, double y0, double y1) { return y0 + (y1 - y0) * @@ -429,62 +421,60 @@ Pwl Awb::interpolatePrior() } } -static double interpolate_quadatric(Pwl::Point const &A, Pwl::Point const &B, - Pwl::Point const &C) +static double interpolateQuadatric(Pwl::Point const &a, Pwl::Point const &b, + Pwl::Point const &c) { // Given 3 points on a curve, find the extremum of the function in that // interval by fitting a quadratic. const double eps = 1e-3; - Pwl::Point CA = C - A, BA = B - A; - double denominator = 2 * (BA.y * CA.x - CA.y * BA.x); + Pwl::Point ca = c - a, ba = b - a; + double denominator = 2 * (ba.y * ca.x - ca.y * ba.x); if (abs(denominator) > eps) { - double numerator = BA.y * CA.x * CA.x - CA.y * BA.x * BA.x; - double result = numerator / denominator + A.x; - return std::max(A.x, std::min(C.x, result)); + double numerator = ba.y * ca.x * ca.x - ca.y * ba.x * ba.x; + double result = numerator / denominator + a.x; + return std::max(a.x, std::min(c.x, result)); } // has degenerated to straight line segment - return A.y < C.y - eps ? A.x : (C.y < A.y - eps ? C.x : B.x); + return a.y < c.y - eps ? a.x : (c.y < a.y - eps ? c.x : b.x); } double Awb::coarseSearch(Pwl const &prior) { points_.clear(); // assume doesn't deallocate memory - size_t best_point = 0; - double t = mode_->ct_lo; - int span_r = 0, span_b = 0; + size_t bestPoint = 0; + double t = mode_->ctLo; + int spanR = 0, spanB = 0; // Step down the CT curve evaluating log likelihood. while (true) { - double r = config_.ct_r.Eval(t, &span_r); - double b = config_.ct_b.Eval(t, &span_b); - double gain_r = 1 / r, gain_b = 1 / b; - double delta2_sum = computeDelta2Sum(gain_r, gain_b); - double prior_log_likelihood = - prior.Eval(prior.Domain().Clip(t)); - double final_log_likelihood = delta2_sum - prior_log_likelihood; + double r = config_.ctR.eval(t, &spanR); + double b = config_.ctB.eval(t, &spanB); + double gainR = 1 / r, gainB = 1 / b; + double delta2Sum = computeDelta2Sum(gainR, gainB); + double priorLogLikelihood = prior.eval(prior.domain().clip(t)); + double finalLogLikelihood = delta2Sum - priorLogLikelihood; LOG(RPiAwb, Debug) - << "t: " << t << " gain_r " << gain_r << " gain_b " - << gain_b << " delta2_sum " << delta2_sum - << " prior " << prior_log_likelihood << " final " - << final_log_likelihood; - points_.push_back(Pwl::Point(t, final_log_likelihood)); - if (points_.back().y < points_[best_point].y) - best_point = points_.size() - 1; - if (t == mode_->ct_hi) + << "t: " << t << " gain R " << gainR << " gain B " + << gainB << " delta2_sum " << delta2Sum + << " prior " << priorLogLikelihood << " final " + << finalLogLikelihood; + points_.push_back(Pwl::Point(t, finalLogLikelihood)); + if (points_.back().y < points_[bestPoint].y) + bestPoint = points_.size() - 1; + if (t == mode_->ctHi) break; // for even steps along the r/b curve scale them by the current t - t = std::min(t + t / 10 * config_.coarse_step, - mode_->ct_hi); + t = std::min(t + t / 10 * config_.coarseStep, mode_->ctHi); } - t = points_[best_point].x; + t = points_[bestPoint].x; LOG(RPiAwb, Debug) << "Coarse search found CT " << t; // We have the best point of the search, but refine it with a quadratic // interpolation around its neighbours. if (points_.size() > 2) { - unsigned long bp = std::min(best_point, points_.size() - 2); - best_point = std::max(1UL, bp); - t = interpolate_quadatric(points_[best_point - 1], - points_[best_point], - points_[best_point + 1]); + unsigned long bp = std::min(bestPoint, points_.size() - 2); + bestPoint = std::max(1UL, bp); + t = interpolateQuadatric(points_[bestPoint - 1], + points_[bestPoint], + points_[bestPoint + 1]); LOG(RPiAwb, Debug) << "After quadratic refinement, coarse search has CT " << t; @@ -494,80 +484,76 @@ double Awb::coarseSearch(Pwl const &prior) void Awb::fineSearch(double &t, double &r, double &b, Pwl const &prior) { - int span_r = -1, span_b = -1; - config_.ct_r.Eval(t, &span_r); - config_.ct_b.Eval(t, &span_b); - double step = t / 10 * config_.coarse_step * 0.1; + int spanR = -1, spanB = -1; + config_.ctR.eval(t, &spanR); + config_.ctB.eval(t, &spanB); + double step = t / 10 * config_.coarseStep * 0.1; int nsteps = 5; - double r_diff = config_.ct_r.Eval(t + nsteps * step, &span_r) - - config_.ct_r.Eval(t - nsteps * step, &span_r); - double b_diff = config_.ct_b.Eval(t + nsteps * step, &span_b) - - config_.ct_b.Eval(t - nsteps * step, &span_b); - Pwl::Point transverse(b_diff, -r_diff); - if (transverse.Len2() < 1e-6) + double rDiff = config_.ctR.eval(t + nsteps * step, &spanR) - + config_.ctR.eval(t - nsteps * step, &spanR); + double bDiff = config_.ctB.eval(t + nsteps * step, &spanB) - + config_.ctB.eval(t - nsteps * step, &spanB); + Pwl::Point transverse(bDiff, -rDiff); + if (transverse.len2() < 1e-6) return; // unit vector orthogonal to the b vs. r function (pointing outwards // with r and b increasing) - transverse = transverse / transverse.Len(); - double best_log_likelihood = 0, best_t = 0, best_r = 0, best_b = 0; - double transverse_range = - config_.transverse_neg + config_.transverse_pos; - const int MAX_NUM_DELTAS = 12; + transverse = transverse / transverse.len(); + double bestLogLikelihood = 0, bestT = 0, bestR = 0, bestB = 0; + double transverseRange = config_.transverseNeg + config_.transversePos; + const int maxNumDeltas = 12; // a transverse step approximately every 0.01 r/b units - int num_deltas = floor(transverse_range * 100 + 0.5) + 1; - num_deltas = num_deltas < 3 ? 3 : - (num_deltas > MAX_NUM_DELTAS ? MAX_NUM_DELTAS : num_deltas); + int numDeltas = floor(transverseRange * 100 + 0.5) + 1; + numDeltas = numDeltas < 3 ? 3 : (numDeltas > maxNumDeltas ? maxNumDeltas : numDeltas); // Step down CT curve. March a bit further if the transverse range is // large. - nsteps += num_deltas; + nsteps += numDeltas; for (int i = -nsteps; i <= nsteps; i++) { - double t_test = t + i * step; - double prior_log_likelihood = - prior.Eval(prior.Domain().Clip(t_test)); - double r_curve = config_.ct_r.Eval(t_test, &span_r); - double b_curve = config_.ct_b.Eval(t_test, &span_b); + double tTest = t + i * step; + double priorLogLikelihood = + prior.eval(prior.domain().clip(tTest)); + double rCurve = config_.ctR.eval(tTest, &spanR); + double bCurve = config_.ctB.eval(tTest, &spanB); // x will be distance off the curve, y the log likelihood there - Pwl::Point points[MAX_NUM_DELTAS]; - int best_point = 0; + Pwl::Point points[maxNumDeltas]; + int bestPoint = 0; // Take some measurements transversely *off* the CT curve. - for (int j = 0; j < num_deltas; j++) { - points[j].x = -config_.transverse_neg + - (transverse_range * j) / (num_deltas - 1); - Pwl::Point rb_test = Pwl::Point(r_curve, b_curve) + - transverse * points[j].x; - double r_test = rb_test.x, b_test = rb_test.y; - double gain_r = 1 / r_test, gain_b = 1 / b_test; - double delta2_sum = computeDelta2Sum(gain_r, gain_b); - points[j].y = delta2_sum - prior_log_likelihood; + for (int j = 0; j < numDeltas; j++) { + points[j].x = -config_.transverseNeg + + (transverseRange * j) / (numDeltas - 1); + Pwl::Point rbTest = Pwl::Point(rCurve, bCurve) + + transverse * points[j].x; + double rTest = rbTest.x, bTest = rbTest.y; + double gainR = 1 / rTest, gainB = 1 / bTest; + double delta2Sum = computeDelta2Sum(gainR, gainB); + points[j].y = delta2Sum - priorLogLikelihood; LOG(RPiAwb, Debug) - << "At t " << t_test << " r " << r_test << " b " - << b_test << ": " << points[j].y; - if (points[j].y < points[best_point].y) - best_point = j; + << "At t " << tTest << " r " << rTest << " b " + << bTest << ": " << points[j].y; + if (points[j].y < points[bestPoint].y) + bestPoint = j; } // We have NUM_DELTAS points transversely across the CT curve, // now let's do a quadratic interpolation for the best result. - best_point = std::max(1, std::min(best_point, num_deltas - 2)); - Pwl::Point rb_test = - Pwl::Point(r_curve, b_curve) + - transverse * - interpolate_quadatric(points[best_point - 1], - points[best_point], - points[best_point + 1]); - double r_test = rb_test.x, b_test = rb_test.y; - double gain_r = 1 / r_test, gain_b = 1 / b_test; - double delta2_sum = computeDelta2Sum(gain_r, gain_b); - double final_log_likelihood = delta2_sum - prior_log_likelihood; + bestPoint = std::max(1, std::min(bestPoint, numDeltas - 2)); + Pwl::Point rbTest = Pwl::Point(rCurve, bCurve) + + transverse * interpolateQuadatric(points[bestPoint - 1], + points[bestPoint], + points[bestPoint + 1]); + double rTest = rbTest.x, bTest = rbTest.y; + double gainR = 1 / rTest, gainB = 1 / bTest; + double delta2Sum = computeDelta2Sum(gainR, gainB); + double finalLogLikelihood = delta2Sum - priorLogLikelihood; LOG(RPiAwb, Debug) << "Finally " - << t_test << " r " << r_test << " b " << b_test << ": " - << final_log_likelihood - << (final_log_likelihood < best_log_likelihood ? " BEST" : ""); - if (best_t == 0 || final_log_likelihood < best_log_likelihood) - best_log_likelihood = final_log_likelihood, - best_t = t_test, best_r = r_test, best_b = b_test; + << tTest << " r " << rTest << " b " << bTest << ": " + << finalLogLikelihood + << (finalLogLikelihood < bestLogLikelihood ? " BEST" : ""); + if (bestT == 0 || finalLogLikelihood < bestLogLikelihood) + bestLogLikelihood = finalLogLikelihood, + bestT = tTest, bestR = rTest, bestB = bTest; } - t = best_t, r = best_r, b = best_b; + t = bestT, r = bestR, b = bestB; LOG(RPiAwb, Debug) << "Fine search found t " << t << " r " << r << " b " << b; } @@ -582,12 +568,12 @@ void Awb::awbBayes() // valid... not entirely sure about this. Pwl prior = interpolatePrior(); prior *= zones_.size() / (double)(AWB_STATS_SIZE_X * AWB_STATS_SIZE_Y); - prior.Map([](double x, double y) { + prior.map([](double x, double y) { LOG(RPiAwb, Debug) << "(" << x << "," << y << ")"; }); double t = coarseSearch(prior); - double r = config_.ct_r.Eval(t); - double b = config_.ct_b.Eval(t); + double r = config_.ctR.eval(t); + double b = config_.ctB.eval(t); LOG(RPiAwb, Debug) << "After coarse search: r " << r << " b " << b << " (gains r " << 1 / r << " b " << 1 / b << ")"; @@ -604,10 +590,10 @@ void Awb::awbBayes() // Write results out for the main thread to pick up. Remember to adjust // the gains from the ones that the "canonical sensor" would require to // the ones needed by *this* sensor. - async_results_.temperature_K = t; - async_results_.gain_r = 1.0 / r * config_.sensitivity_r; - async_results_.gain_g = 1.0; - async_results_.gain_b = 1.0 / b * config_.sensitivity_b; + asyncResults_.temperatureK = t; + asyncResults_.gainR = 1.0 / r * config_.sensitivityR; + asyncResults_.gainG = 1.0; + asyncResults_.gainB = 1.0 / b * config_.sensitivityB; } void Awb::awbGrey() @@ -617,51 +603,51 @@ void Awb::awbGrey() // that we can sort them to exclude the extreme gains. We could // consider some variations, such as normalising all the zones first, or // doing an L2 average etc. - std::vector &derivs_R(zones_); - std::vector derivs_B(derivs_R); - std::sort(derivs_R.begin(), derivs_R.end(), + std::vector &derivsR(zones_); + std::vector derivsB(derivsR); + std::sort(derivsR.begin(), derivsR.end(), [](RGB const &a, RGB const &b) { return a.G * b.R < b.G * a.R; }); - std::sort(derivs_B.begin(), derivs_B.end(), + std::sort(derivsB.begin(), derivsB.end(), [](RGB const &a, RGB const &b) { return a.G * b.B < b.G * a.B; }); // Average the middle half of the values. - int discard = derivs_R.size() / 4; - RGB sum_R(0, 0, 0), sum_B(0, 0, 0); - for (auto ri = derivs_R.begin() + discard, - bi = derivs_B.begin() + discard; - ri != derivs_R.end() - discard; ri++, bi++) - sum_R += *ri, sum_B += *bi; - double gain_r = sum_R.G / (sum_R.R + 1), - gain_b = sum_B.G / (sum_B.B + 1); - async_results_.temperature_K = 4500; // don't know what it is - async_results_.gain_r = gain_r; - async_results_.gain_g = 1.0; - async_results_.gain_b = gain_b; + int discard = derivsR.size() / 4; + RGB sumR(0, 0, 0), sumB(0, 0, 0); + for (auto ri = derivsR.begin() + discard, + bi = derivsB.begin() + discard; + ri != derivsR.end() - discard; ri++, bi++) + sumR += *ri, sumB += *bi; + double gainR = sumR.G / (sumR.R + 1), + gainB = sumB.G / (sumB.B + 1); + asyncResults_.temperatureK = 4500; // don't know what it is + asyncResults_.gainR = gainR; + asyncResults_.gainG = 1.0; + asyncResults_.gainB = gainB; } void Awb::doAwb() { prepareStats(); LOG(RPiAwb, Debug) << "Valid zones: " << zones_.size(); - if (zones_.size() > config_.min_regions) { + if (zones_.size() > config_.minRegions) { if (config_.bayes) awbBayes(); else awbGrey(); LOG(RPiAwb, Debug) << "CT found is " - << async_results_.temperature_K - << " with gains r " << async_results_.gain_r - << " and b " << async_results_.gain_b; + << asyncResults_.temperatureK + << " with gains r " << asyncResults_.gainR + << " and b " << asyncResults_.gainB; } } // Register algorithm with the system. -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return (Algorithm *)new Awb(controller); } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp b/src/ipa/raspberrypi/controller/rpi/awb.hpp index ac3dca6f42fc..91251d6be2da 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.hpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp @@ -19,59 +19,59 @@ namespace RPiController { // Control algorithm to perform AWB calculations. struct AwbMode { - void Read(boost::property_tree::ptree const ¶ms); - double ct_lo; // low CT value for search - double ct_hi; // high CT value for search + void read(boost::property_tree::ptree const ¶ms); + double ctLo; // low CT value for search + double ctHi; // high CT value for search }; struct AwbPrior { - void Read(boost::property_tree::ptree const ¶ms); + void read(boost::property_tree::ptree const ¶ms); double lux; // lux level Pwl prior; // maps CT to prior log likelihood for this lux level }; struct AwbConfig { - AwbConfig() : default_mode(nullptr) {} - void Read(boost::property_tree::ptree const ¶ms); + AwbConfig() : defaultMode(nullptr) {} + void read(boost::property_tree::ptree const ¶ms); // Only repeat the AWB calculation every "this many" frames - uint16_t frame_period; + uint16_t framePeriod; // number of initial frames for which speed taken as 1.0 (maximum) - uint16_t startup_frames; - unsigned int convergence_frames; // approx number of frames to converge + uint16_t startupFrames; + unsigned int convergenceFrames; // approx number of frames to converge double speed; // IIR filter speed applied to algorithm results bool fast; // "fast" mode uses a 16x16 rather than 32x32 grid - Pwl ct_r; // function maps CT to r (= R/G) - Pwl ct_b; // function maps CT to b (= B/G) + Pwl ctR; // function maps CT to r (= R/G) + Pwl ctB; // function maps CT to b (= B/G) // table of illuminant priors at different lux levels std::vector priors; // AWB "modes" (determines the search range) std::map modes; - AwbMode *default_mode; // mode used if no mode selected + AwbMode *defaultMode; // mode used if no mode selected // minimum proportion of pixels counted within AWB region for it to be // "useful" - double min_pixels; + double minPixels; // minimum G value of those pixels, to be regarded a "useful" - uint16_t min_G; + uint16_t minG; // number of AWB regions that must be "useful" in order to do the AWB // calculation - uint32_t min_regions; + uint32_t minRegions; // clamp on colour error term (so as not to penalise non-grey excessively) - double delta_limit; + double deltaLimit; // step size control in coarse search - double coarse_step; + double coarseStep; // how far to wander off CT curve towards "more purple" - double transverse_pos; + double transversePos; // how far to wander off CT curve towards "more green" - double transverse_neg; + double transverseNeg; // red sensitivity ratio (set to canonical sensor's R/G divided by this // sensor's R/G) - double sensitivity_r; + double sensitivityR; // blue sensitivity ratio (set to canonical sensor's B/G divided by this // sensor's B/G) - double sensitivity_b; + double sensitivityB; // The whitepoint (which we normally "aim" for) can be moved. - double whitepoint_r; - double whitepoint_b; + double whitepointR; + double whitepointB; bool bayes; // use Bayesian algorithm }; @@ -80,22 +80,22 @@ class Awb : public AwbAlgorithm public: Awb(Controller *controller = NULL); ~Awb(); - char const *Name() const override; - void Initialise() override; - void Read(boost::property_tree::ptree const ¶ms) override; + char const *name() const override; + void initialise() override; + void read(boost::property_tree::ptree const ¶ms) override; // AWB handles "pausing" for itself. - bool IsPaused() const override; - void Pause() override; - void Resume() override; - unsigned int GetConvergenceFrames() const override; - void SetMode(std::string const &name) override; - void SetManualGains(double manual_r, double manual_b) override; - void SwitchMode(CameraMode const &camera_mode, Metadata *metadata) override; - void Prepare(Metadata *image_metadata) override; - void Process(StatisticsPtr &stats, Metadata *image_metadata) override; + bool isPaused() const override; + void pause() override; + void resume() override; + unsigned int getConvergenceFrames() const override; + void setMode(std::string const &name) override; + void setManualGains(double manualR, double manualB) override; + void switchMode(CameraMode const &cameraMode, Metadata *metadata) override; + void prepare(Metadata *imageMetadata) override; + void process(StatisticsPtr &stats, Metadata *imageMetadata) override; struct RGB { - RGB(double _R = 0, double _G = 0, double _B = 0) - : R(_R), G(_G), B(_B) + RGB(double r = 0, double g = 0, double b = 0) + : R(r), G(g), B(b) { } double R, G, B; @@ -110,29 +110,29 @@ private: bool isAutoEnabled() const; // configuration is read-only, and available to both threads AwbConfig config_; - std::thread async_thread_; + std::thread asyncThread_; void asyncFunc(); // asynchronous thread function std::mutex mutex_; // condvar for async thread to wait on - std::condition_variable async_signal_; + std::condition_variable asyncSignal_; // condvar for synchronous thread to wait on - std::condition_variable sync_signal_; + std::condition_variable syncSignal_; // for sync thread to check if async thread finished (requires mutex) - bool async_finished_; + bool asyncFinished_; // for async thread to check if it's been told to run (requires mutex) - bool async_start_; + bool asyncStart_; // for async thread to check if it's been told to quit (requires mutex) - bool async_abort_; + bool asyncAbort_; // The following are only for the synchronous thread to use: // for sync thread to note its has asked async thread to run - bool async_started_; - // counts up to frame_period before restarting the async thread - int frame_phase_; - int frame_count_; // counts up to startup_frames - AwbStatus sync_results_; - AwbStatus prev_sync_results_; - std::string mode_name_; + bool asyncStarted_; + // counts up to framePeriod before restarting the async thread + int framePhase_; + int frameCount_; // counts up to startup_frames + AwbStatus syncResults_; + AwbStatus prevSyncResults_; + std::string modeName_; // The following are for the asynchronous thread to use, though the main // thread can set/reset them if the async thread is known to be idle: void restartAsync(StatisticsPtr &stats, double lux); @@ -141,22 +141,22 @@ private: StatisticsPtr statistics_; AwbMode *mode_; double lux_; - AwbStatus async_results_; + AwbStatus asyncResults_; void doAwb(); void awbBayes(); void awbGrey(); void prepareStats(); - double computeDelta2Sum(double gain_r, double gain_b); + double computeDelta2Sum(double gain_r, double gainB); Pwl interpolatePrior(); double coarseSearch(Pwl const &prior); void fineSearch(double &t, double &r, double &b, Pwl const &prior); std::vector zones_; std::vector points_; // manual r setting - double manual_r_; + double manualR_; // manual b setting - double manual_b_; - bool first_switch_mode_; // is this the first call to SwitchMode? + double manualB_; + bool firstSwitchMode_; // is this the first call to SwitchMode? }; static inline Awb::RGB operator+(Awb::RGB const &a, Awb::RGB const &b) From patchwork Tue Jul 26 12:45:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16781 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 21292C3275 for ; Tue, 26 Jul 2022 12:46:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B28536331C; Tue, 26 Jul 2022 14:46:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839568; bh=QO35yZnt0woM4gUBa9xZXM+Scv1x9CAVfUHOAqb6VHI=; 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=1kM2SVIMIb2hl0xaJOAjk9wmiGOPFdqvsopWJkbN/TC8iw0Bs4MiKN0n86YxiY3Zb qhO6iHBdhO6i8QFNXKEuwL6q7mpjJ+9fgCWzP4ShI1rnXwHjxuTQASX39c9WekT0Oc Z+834kmItU5X2Suy6JLJRFeFsDL+9AHSg1FcFHvuoMEIlH/2BBQob1wUOKRgjXlFa1 ZuSuv/bY148uPezYZoLy5IH6dDMgcV9DI6zW/gljFhFPmbX/DATWlMDmKxUWU7poqz ExFhHxqpLrkhUSyOOp57x4JmdwEK1fnRB+S/K4AwJ8VV+3YgPSgeOj5RMwf3me3svk BxLILEGIHQ7dA== Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C09726331C for ; Tue, 26 Jul 2022 14:46:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="EqyVT1rc"; dkim-atps=neutral Received: by mail-wm1-x331.google.com with SMTP id b21-20020a05600c4e1500b003a32bc8612fso8093507wmq.3 for ; Tue, 26 Jul 2022 05:46:04 -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=hAGPSSJvx902LtVAushGNNjOrVHyzSw5YGgJ1D+1AZw=; b=EqyVT1rcXxLyu9+4ZmCrtStqBYynVEtSvlD+WYaLfbRPi3cd/wmNeK369cc4+vKSor WQorr92OljXTEJneMKxfw4WZhyCgEv30ClA2se7HruIKDRPcQM0fSw3BJ5eALt6KmqGl 7Aqy4LfHg0sRZFXSLcX2APtdoH0/6n8isF60z9x2dYQ/RRznHQpMhNl37a0huGgOTd6O s4ipfFthKPqNl5XBRAvJO9VzWxl8IOPDK9ipGD1Dth8ZTh+9dqSF5nh2sSqAyNL2dkta gNKpYoi2Nw1HTt6Cy225txi/+796qkq9YlBF0RMxKmbhXgI/TVLOMM3KidArYkr8riCY DUjA== 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=hAGPSSJvx902LtVAushGNNjOrVHyzSw5YGgJ1D+1AZw=; b=UW7fwa8CGsEFTLZ0xdIBPPmmJpI4OZuLHlRDd/9YeXVKzV3SVI4xJXDlRAymjaZMdN fPgcCDaU7bDhHh2COCPFcf4b1S+yOyEIHkAgDiByni8z+KNpB/mtWs+hU8rFVyqYPbDg Cg+mKdtGB8l9sQoNhbpCkkPiUDFHTBHJMZkN+K+kel6BFaU4yL3w5xBaKs4LNvGgmOCy 5xp0DutKJNJi6VKJk1fcz1yp23MHFW4UYHFgsvoKcpDLA7r3IvVW+/h9GBpovx/QCxmz Whxmqn6c6wpGPXPNVOGUyRqPX+4wga5jY/L2VYNvyYNu6ip1Wf+qt3ngFlq9P5ZyyrXB A0Sw== X-Gm-Message-State: AJIora94v9H95X2ZL9L274TsIYxHaQwy3FDd5uRL4t4gKgEERYEAZQFy Zx2z1zZNB6P3VDe9g7uejaiKSPPX/5EBKA== X-Google-Smtp-Source: AGRyM1upYnl7vfbH/riMtf7XRRd4Q4M8Hj7/YR+eWnLdx2E9fn27eiA/UaoFqhNxRq/85jPQsW5xCQ== X-Received: by 2002:a05:600c:3ac7:b0:3a3:64c3:6ddf with SMTP id d7-20020a05600c3ac700b003a364c36ddfmr5970643wms.105.1658839563425; Tue, 26 Jul 2022 05:46:03 -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.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:46:02 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:40 +0100 Message-Id: <20220726124549.1646-9-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 08/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 src/ipa/raspberrypi/controller/rps/[b|c|d]* 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 --- .../controller/black_level_status.h | 6 +- src/ipa/raspberrypi/controller/rpi/agc.cpp | 2 +- .../controller/rpi/black_level.cpp | 34 ++--- .../controller/rpi/black_level.hpp | 12 +- src/ipa/raspberrypi/controller/rpi/ccm.cpp | 84 +++++++------ src/ipa/raspberrypi/controller/rpi/ccm.hpp | 12 +- .../raspberrypi/controller/rpi/contrast.cpp | 118 +++++++++--------- .../raspberrypi/controller/rpi/contrast.hpp | 30 ++--- src/ipa/raspberrypi/controller/rpi/dpc.cpp | 18 +-- src/ipa/raspberrypi/controller/rpi/dpc.hpp | 6 +- 10 files changed, 160 insertions(+), 162 deletions(-) diff --git a/src/ipa/raspberrypi/controller/black_level_status.h b/src/ipa/raspberrypi/controller/black_level_status.h index d085f64b27fe..df3661401d99 100644 --- a/src/ipa/raspberrypi/controller/black_level_status.h +++ b/src/ipa/raspberrypi/controller/black_level_status.h @@ -13,9 +13,9 @@ extern "C" { #endif struct BlackLevelStatus { - uint16_t black_level_r; // out of 16 bits - uint16_t black_level_g; - uint16_t black_level_b; + uint16_t blackLevelR; // out of 16 bits + uint16_t blackLevelG; + uint16_t blackLevelB; }; #ifdef __cplusplus diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index c19769f4e27b..408ff9cf296d 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -250,7 +250,7 @@ void Agc::setFixedShutter(Duration fixedShutter) void Agc::setFixedAnalogueGain(double fixedAnalogueGain) { - fixedAnalogueGain_ = fixedAnalogueGain_; + fixedAnalogueGain_ = fixedAnalogueGain; // Set this in case someone calls Pause() straight after. status_.analogueGain = fixedAnalogueGain; } diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.cpp b/src/ipa/raspberrypi/controller/rpi/black_level.cpp index 6b3497f13c19..101b5ea92cf5 100644 --- a/src/ipa/raspberrypi/controller/rpi/black_level.cpp +++ b/src/ipa/raspberrypi/controller/rpi/black_level.cpp @@ -26,38 +26,38 @@ BlackLevel::BlackLevel(Controller *controller) { } -char const *BlackLevel::Name() const +char const *BlackLevel::name() const { return NAME; } -void BlackLevel::Read(boost::property_tree::ptree const ¶ms) +void BlackLevel::read(boost::property_tree::ptree const ¶ms) { - uint16_t black_level = params.get( + uint16_t blackLevel = params.get( "black_level", 4096); // 64 in 10 bits scaled to 16 bits - black_level_r_ = params.get("black_level_r", black_level); - black_level_g_ = params.get("black_level_g", black_level); - black_level_b_ = params.get("black_level_b", black_level); + blackLevelR_ = params.get("blackLevelR", blackLevel); + blackLevelG_ = params.get("blackLevelG", blackLevel); + blackLevelB_ = params.get("blackLevelB", blackLevel); LOG(RPiBlackLevel, Debug) - << " Read black levels red " << black_level_r_ - << " green " << black_level_g_ - << " blue " << black_level_b_; + << " Read black levels red " << blackLevelR_ + << " green " << blackLevelG_ + << " blue " << blackLevelB_; } -void BlackLevel::Prepare(Metadata *image_metadata) +void BlackLevel::prepare(Metadata *imageMetadata) { - // Possibly we should think about doing this in a switch_mode or + // Possibly we should think about doing this in a switchMode or // something? struct BlackLevelStatus status; - status.black_level_r = black_level_r_; - status.black_level_g = black_level_g_; - status.black_level_b = black_level_b_; - image_metadata->Set("black_level.status", status); + status.blackLevelR = blackLevelR_; + status.blackLevelG = blackLevelG_; + status.blackLevelB = blackLevelB_; + imageMetadata->set("black_level.status", status); } // Register algorithm with the system. -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return new BlackLevel(controller); } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.hpp b/src/ipa/raspberrypi/controller/rpi/black_level.hpp index 65ec4d0ed26c..0d74f6a4c49b 100644 --- a/src/ipa/raspberrypi/controller/rpi/black_level.hpp +++ b/src/ipa/raspberrypi/controller/rpi/black_level.hpp @@ -17,14 +17,14 @@ class BlackLevel : public Algorithm { public: BlackLevel(Controller *controller); - char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; - void Prepare(Metadata *image_metadata) override; + char const *name() const override; + void read(boost::property_tree::ptree const ¶ms) override; + void prepare(Metadata *imageMetadata) override; private: - double black_level_r_; - double black_level_g_; - double black_level_b_; + double blackLevelR_; + double blackLevelG_; + double blackLevelB_; }; } // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.cpp b/src/ipa/raspberrypi/controller/rpi/ccm.cpp index 821a4c7c98c5..24d8e5bd1fd8 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.cpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.cpp @@ -37,7 +37,7 @@ Matrix::Matrix(double m0, double m1, double m2, double m3, double m4, double m5, m[0][0] = m0, m[0][1] = m1, m[0][2] = m2, m[1][0] = m3, m[1][1] = m4, m[1][2] = m5, m[2][0] = m6, m[2][1] = m7, m[2][2] = m8; } -void Matrix::Read(boost::property_tree::ptree const ¶ms) +void Matrix::read(boost::property_tree::ptree const ¶ms) { double *ptr = (double *)m; int n = 0; @@ -53,47 +53,49 @@ void Matrix::Read(boost::property_tree::ptree const ¶ms) Ccm::Ccm(Controller *controller) : CcmAlgorithm(controller), saturation_(1.0) {} -char const *Ccm::Name() const +char const *Ccm::name() const { return NAME; } -void Ccm::Read(boost::property_tree::ptree const ¶ms) +void Ccm::read(boost::property_tree::ptree const ¶ms) { if (params.get_child_optional("saturation")) - config_.saturation.Read(params.get_child("saturation")); + config_.saturation.read(params.get_child("saturation")); for (auto &p : params.get_child("ccms")) { - CtCcm ct_ccm; - ct_ccm.ct = p.second.get("ct"); - ct_ccm.ccm.Read(p.second.get_child("ccm")); + CtCcm ctCcm; + ctCcm.ct = p.second.get("ct"); + ctCcm.ccm.read(p.second.get_child("ccm")); if (!config_.ccms.empty() && - ct_ccm.ct <= config_.ccms.back().ct) + ctCcm.ct <= config_.ccms.back().ct) throw std::runtime_error( "Ccm: CCM not in increasing colour temperature order"); - config_.ccms.push_back(std::move(ct_ccm)); + config_.ccms.push_back(std::move(ctCcm)); } if (config_.ccms.empty()) throw std::runtime_error("Ccm: no CCMs specified"); } -void Ccm::SetSaturation(double saturation) +void Ccm::setSaturation(double saturation) { saturation_ = saturation; } -void Ccm::Initialise() {} +void Ccm::initialise() +{ +} template -static bool get_locked(Metadata *metadata, std::string const &tag, T &value) +static bool getLocked(Metadata *metadata, std::string const &tag, T &value) { - T *ptr = metadata->GetLocked(tag); + T *ptr = metadata->getLocked(tag); if (ptr == nullptr) return false; value = *ptr; return true; } -Matrix calculate_ccm(std::vector const &ccms, double ct) +Matrix calculateCcm(std::vector const &ccms, double ct) { if (ct <= ccms.front().ct) return ccms.front().ccm; @@ -109,7 +111,7 @@ Matrix calculate_ccm(std::vector const &ccms, double ct) } } -Matrix apply_saturation(Matrix const &ccm, double saturation) +Matrix applySaturation(Matrix const &ccm, double saturation) { Matrix RGB2Y(0.299, 0.587, 0.114, -0.169, -0.331, 0.500, 0.500, -0.419, -0.081); @@ -119,51 +121,51 @@ Matrix apply_saturation(Matrix const &ccm, double saturation) return Y2RGB * S * RGB2Y * ccm; } -void Ccm::Prepare(Metadata *image_metadata) +void Ccm::prepare(Metadata *imageMetadata) { - bool awb_ok = false, lux_ok = false; + bool awbOk = false, luxOk = false; struct AwbStatus awb = {}; - awb.temperature_K = 4000; // in case no metadata + awb.temperatureK = 4000; // in case no metadata struct LuxStatus lux = {}; lux.lux = 400; // in case no metadata { // grab mutex just once to get everything - std::lock_guard lock(*image_metadata); - awb_ok = get_locked(image_metadata, "awb.status", awb); - lux_ok = get_locked(image_metadata, "lux.status", lux); + std::lock_guard lock(*imageMetadata); + awbOk = getLocked(imageMetadata, "awb.status", awb); + luxOk = getLocked(imageMetadata, "lux.status", lux); } - if (!awb_ok) + if (!awbOk) LOG(RPiCcm, Warning) << "no colour temperature found"; - if (!lux_ok) + if (!luxOk) LOG(RPiCcm, Warning) << "no lux value found"; - Matrix ccm = calculate_ccm(config_.ccms, awb.temperature_K); + Matrix ccm = calculateCcm(config_.ccms, awb.temperatureK); double saturation = saturation_; - struct CcmStatus ccm_status; - ccm_status.saturation = saturation; - if (!config_.saturation.Empty()) - saturation *= config_.saturation.Eval( - config_.saturation.Domain().Clip(lux.lux)); - ccm = apply_saturation(ccm, saturation); + struct CcmStatus ccmStatus; + ccmStatus.saturation = saturation; + if (!config_.saturation.empty()) + saturation *= config_.saturation.eval( + config_.saturation.domain().clip(lux.lux)); + ccm = applySaturation(ccm, saturation); for (int j = 0; j < 3; j++) for (int i = 0; i < 3; i++) - ccm_status.matrix[j * 3 + i] = + ccmStatus.matrix[j * 3 + i] = std::max(-8.0, std::min(7.9999, ccm.m[j][i])); LOG(RPiCcm, Debug) - << "colour temperature " << awb.temperature_K << "K"; + << "colour temperature " << awb.temperatureK << "K"; LOG(RPiCcm, Debug) - << "CCM: " << ccm_status.matrix[0] << " " << ccm_status.matrix[1] - << " " << ccm_status.matrix[2] << " " - << ccm_status.matrix[3] << " " << ccm_status.matrix[4] - << " " << ccm_status.matrix[5] << " " - << ccm_status.matrix[6] << " " << ccm_status.matrix[7] - << " " << ccm_status.matrix[8]; - image_metadata->Set("ccm.status", ccm_status); + << "CCM: " << ccmStatus.matrix[0] << " " << ccmStatus.matrix[1] + << " " << ccmStatus.matrix[2] << " " + << ccmStatus.matrix[3] << " " << ccmStatus.matrix[4] + << " " << ccmStatus.matrix[5] << " " + << ccmStatus.matrix[6] << " " << ccmStatus.matrix[7] + << " " << ccmStatus.matrix[8]; + imageMetadata->set("ccm.status", ccmStatus); } // Register algorithm with the system. -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return (Algorithm *)new Ccm(controller); ; } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.hpp b/src/ipa/raspberrypi/controller/rpi/ccm.hpp index 330ed51fe398..4c4807b8a942 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.hpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.hpp @@ -20,7 +20,7 @@ struct Matrix { double m6, double m7, double m8); Matrix(); double m[3][3]; - void Read(boost::property_tree::ptree const ¶ms); + void read(boost::property_tree::ptree const ¶ms); }; static inline Matrix operator*(double d, Matrix const &m) { @@ -61,11 +61,11 @@ class Ccm : public CcmAlgorithm { public: Ccm(Controller *controller = NULL); - char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; - void SetSaturation(double saturation) override; - void Initialise() override; - void Prepare(Metadata *image_metadata) override; + char const *name() const override; + void read(boost::property_tree::ptree const ¶ms) override; + void setSaturation(double saturation) override; + void initialise() override; + void prepare(Metadata *imageMetadata) override; private: CcmConfig config_; diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.cpp b/src/ipa/raspberrypi/controller/rpi/contrast.cpp index ae55aad56739..169837576678 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.cpp +++ b/src/ipa/raspberrypi/controller/rpi/contrast.cpp @@ -31,40 +31,40 @@ Contrast::Contrast(Controller *controller) { } -char const *Contrast::Name() const +char const *Contrast::name() const { return NAME; } -void Contrast::Read(boost::property_tree::ptree const ¶ms) +void Contrast::read(boost::property_tree::ptree const ¶ms) { // enable adaptive enhancement by default - config_.ce_enable = params.get("ce_enable", 1); + config_.ceEnable = params.get("ce_enable", 1); // the point near the bottom of the histogram to move - config_.lo_histogram = params.get("lo_histogram", 0.01); + config_.loHistogram = params.get("lo_histogram", 0.01); // where in the range to try and move it to - config_.lo_level = params.get("lo_level", 0.015); + config_.loLevel = params.get("lo_level", 0.015); // but don't move by more than this - config_.lo_max = params.get("lo_max", 500); + config_.loMax = params.get("lo_max", 500); // equivalent values for the top of the histogram... - config_.hi_histogram = params.get("hi_histogram", 0.95); - config_.hi_level = params.get("hi_level", 0.95); - config_.hi_max = params.get("hi_max", 2000); - config_.gamma_curve.Read(params.get_child("gamma_curve")); + config_.hiHistogram = params.get("hi_histogram", 0.95); + config_.hiLevel = params.get("hi_level", 0.95); + config_.hiMax = params.get("hi_max", 2000); + config_.gammaCurve.read(params.get_child("gamma_curve")); } -void Contrast::SetBrightness(double brightness) +void Contrast::setBrightness(double brightness) { brightness_ = brightness; } -void Contrast::SetContrast(double contrast) +void Contrast::setContrast(double contrast) { contrast_ = contrast; } -static void fill_in_status(ContrastStatus &status, double brightness, - double contrast, Pwl &gamma_curve) +static void fillInStatus(ContrastStatus &status, double brightness, + double contrast, Pwl &gammaCurve) { status.brightness = brightness; status.contrast = contrast; @@ -73,104 +73,100 @@ static void fill_in_status(ContrastStatus &status, double brightness, : (i < 24 ? (i - 16) * 2048 + 16384 : (i - 24) * 4096 + 32768); status.points[i].x = x; - status.points[i].y = std::min(65535.0, gamma_curve.Eval(x)); + status.points[i].y = std::min(65535.0, gammaCurve.eval(x)); } status.points[CONTRAST_NUM_POINTS - 1].x = 65535; status.points[CONTRAST_NUM_POINTS - 1].y = 65535; } -void Contrast::Initialise() +void Contrast::initialise() { // Fill in some default values as Prepare will run before Process gets // called. - fill_in_status(status_, brightness_, contrast_, config_.gamma_curve); + fillInStatus(status_, brightness_, contrast_, config_.gammaCurve); } -void Contrast::Prepare(Metadata *image_metadata) +void Contrast::prepare(Metadata *imageMetadata) { std::unique_lock lock(mutex_); - image_metadata->Set("contrast.status", status_); + imageMetadata->set("contrast.status", status_); } -Pwl compute_stretch_curve(Histogram const &histogram, - ContrastConfig const &config) +Pwl computeStretchCurve(Histogram const &histogram, + ContrastConfig const &config) { Pwl enhance; - enhance.Append(0, 0); + enhance.append(0, 0); // If the start of the histogram is rather empty, try to pull it down a // bit. - double hist_lo = histogram.Quantile(config.lo_histogram) * - (65536 / NUM_HISTOGRAM_BINS); - double level_lo = config.lo_level * 65536; + double histLo = histogram.quantile(config.loHistogram) * + (65536 / NUM_HISTOGRAM_BINS); + double levelLo = config.loLevel * 65536; LOG(RPiContrast, Debug) - << "Move histogram point " << hist_lo << " to " << level_lo; - hist_lo = std::max( - level_lo, - std::min(65535.0, std::min(hist_lo, level_lo + config.lo_max))); + << "Move histogram point " << histLo << " to " << levelLo; + histLo = std::max(levelLo, + std::min(65535.0, std::min(histLo, levelLo + config.loMax))); LOG(RPiContrast, Debug) - << "Final values " << hist_lo << " -> " << level_lo; - enhance.Append(hist_lo, level_lo); + << "Final values " << histLo << " -> " << levelLo; + enhance.append(histLo, levelLo); // Keep the mid-point (median) in the same place, though, to limit the // apparent amount of global brightness shift. - double mid = histogram.Quantile(0.5) * (65536 / NUM_HISTOGRAM_BINS); - enhance.Append(mid, mid); + double mid = histogram.quantile(0.5) * (65536 / NUM_HISTOGRAM_BINS); + enhance.append(mid, mid); // If the top to the histogram is empty, try to pull the pixel values // there up. - double hist_hi = histogram.Quantile(config.hi_histogram) * - (65536 / NUM_HISTOGRAM_BINS); - double level_hi = config.hi_level * 65536; + double histHi = histogram.quantile(config.hiHistogram) * + (65536 / NUM_HISTOGRAM_BINS); + double levelHi = config.hiLevel * 65536; LOG(RPiContrast, Debug) - << "Move histogram point " << hist_hi << " to " << level_hi; - hist_hi = std::min( - level_hi, - std::max(0.0, std::max(hist_hi, level_hi - config.hi_max))); + << "Move histogram point " << histHi << " to " << levelHi; + histHi = std::min(levelHi, + std::max(0.0, std::max(histHi, levelHi - config.hiMax))); LOG(RPiContrast, Debug) - << "Final values " << hist_hi << " -> " << level_hi; - enhance.Append(hist_hi, level_hi); - enhance.Append(65535, 65535); + << "Final values " << histHi << " -> " << levelHi; + enhance.append(histHi, levelHi); + enhance.append(65535, 65535); return enhance; } -Pwl apply_manual_contrast(Pwl const &gamma_curve, double brightness, - double contrast) +Pwl applyManualContrast(Pwl const &gammaCurve, double brightness, + double contrast) { - Pwl new_gamma_curve; + Pwl newGammaCurve; LOG(RPiContrast, Debug) << "Manual brightness " << brightness << " contrast " << contrast; - gamma_curve.Map([&](double x, double y) { - new_gamma_curve.Append( + gammaCurve.map([&](double x, double y) { + newGammaCurve.append( x, std::max(0.0, std::min(65535.0, (y - 32768) * contrast + 32768 + brightness))); }); - return new_gamma_curve; + return newGammaCurve; } -void Contrast::Process(StatisticsPtr &stats, - [[maybe_unused]] Metadata *image_metadata) +void Contrast::process(StatisticsPtr &stats, + [[maybe_unused]] Metadata *imageMetadata) { Histogram histogram(stats->hist[0].g_hist, NUM_HISTOGRAM_BINS); // We look at the histogram and adjust the gamma curve in the following // ways: 1. Adjust the gamma curve so as to pull the start of the // histogram down, and possibly push the end up. - Pwl gamma_curve = config_.gamma_curve; - if (config_.ce_enable) { - if (config_.lo_max != 0 || config_.hi_max != 0) - gamma_curve = compute_stretch_curve(histogram, config_) - .Compose(gamma_curve); + Pwl gammaCurve = config_.gammaCurve; + if (config_.ceEnable) { + if (config_.loMax != 0 || config_.hiMax != 0) + gammaCurve = computeStretchCurve(histogram, config_).compose(gammaCurve); // We could apply other adjustments (e.g. partial equalisation) // based on the histogram...? } // 2. Finally apply any manually selected brightness/contrast // adjustment. if (brightness_ != 0 || contrast_ != 1.0) - gamma_curve = apply_manual_contrast(gamma_curve, brightness_, - contrast_); + gammaCurve = applyManualContrast(gammaCurve, brightness_, contrast_); // And fill in the status for output. Use more points towards the bottom // of the curve. ContrastStatus status; - fill_in_status(status, brightness_, contrast_, gamma_curve); + fillInStatus(status, brightness_, contrast_, gammaCurve); { std::unique_lock lock(mutex_); status_ = status; @@ -178,8 +174,8 @@ void Contrast::Process(StatisticsPtr &stats, } // Register algorithm with the system. -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return (Algorithm *)new Contrast(controller); } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.hpp b/src/ipa/raspberrypi/controller/rpi/contrast.hpp index 85624539a1da..5a6d530f63fd 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.hpp +++ b/src/ipa/raspberrypi/controller/rpi/contrast.hpp @@ -17,27 +17,27 @@ namespace RPiController { // Back End AWB. struct ContrastConfig { - bool ce_enable; - double lo_histogram; - double lo_level; - double lo_max; - double hi_histogram; - double hi_level; - double hi_max; - Pwl gamma_curve; + bool ceEnable; + double loHistogram; + double loLevel; + double loMax; + double hiHistogram; + double hiLevel; + double hiMax; + Pwl gammaCurve; }; class Contrast : public ContrastAlgorithm { public: Contrast(Controller *controller = NULL); - char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; - void SetBrightness(double brightness) override; - void SetContrast(double contrast) override; - void Initialise() override; - void Prepare(Metadata *image_metadata) override; - void Process(StatisticsPtr &stats, Metadata *image_metadata) override; + char const *name() const override; + void read(boost::property_tree::ptree const ¶ms) override; + void setBrightness(double brightness) override; + void setContrast(double contrast) override; + void initialise() override; + void prepare(Metadata *imageMetadata) override; + void process(StatisticsPtr &stats, Metadata *imageMetadata) override; private: ContrastConfig config_; diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.cpp b/src/ipa/raspberrypi/controller/rpi/dpc.cpp index 110f50560e76..42154cf300b8 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/dpc.cpp @@ -24,30 +24,30 @@ Dpc::Dpc(Controller *controller) { } -char const *Dpc::Name() const +char const *Dpc::name() const { return NAME; } -void Dpc::Read(boost::property_tree::ptree const ¶ms) +void Dpc::read(boost::property_tree::ptree const ¶ms) { config_.strength = params.get("strength", 1); if (config_.strength < 0 || config_.strength > 2) throw std::runtime_error("Dpc: bad strength value"); } -void Dpc::Prepare(Metadata *image_metadata) +void Dpc::prepare(Metadata *imageMetadata) { - DpcStatus dpc_status = {}; + DpcStatus dpcStatus = {}; // Should we vary this with lux level or analogue gain? TBD. - dpc_status.strength = config_.strength; - LOG(RPiDpc, Debug) << "strength " << dpc_status.strength; - image_metadata->Set("dpc.status", dpc_status); + dpcStatus.strength = config_.strength; + LOG(RPiDpc, Debug) << "strength " << dpcStatus.strength; + imageMetadata->set("dpc.status", dpcStatus); } // Register algorithm with the system. -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return (Algorithm *)new Dpc(controller); } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.hpp b/src/ipa/raspberrypi/controller/rpi/dpc.hpp index d90285c4eb56..039310cc8d05 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/dpc.hpp @@ -21,9 +21,9 @@ class Dpc : public Algorithm { public: Dpc(Controller *controller); - char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; - void Prepare(Metadata *image_metadata) override; + char const *name() const override; + void read(boost::property_tree::ptree const ¶ms) override; + void prepare(Metadata *imageMetadata) override; private: DpcConfig config_; From patchwork Tue Jul 26 12:45:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16782 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 3F036C3275 for ; Tue, 26 Jul 2022 12:46:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CCCA063331; Tue, 26 Jul 2022 14:46:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839569; bh=MrGiF9VO/RPYTur3ZPQxhi3q2+T9zGx+WewZhBx/N3s=; 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=a4+ickVICypJXCb/umvS1DmqeihKbSw+bxaArgA1ULO7slyLL7AprC1pHdVC3Sohd uht+Tn3ie1l9xqS6AMwgvGKNIA9nxiJ622AgoTYpA5+ebXgD1tdkw3x/cKDT46uv0H tUeGB2rqKUr7bvi6o88Rltd/zwxewsxVPIcQQagSBOV3WjZXdKqAW8Da4FfEqk1IAR Z4MgkpdCoN53uVybIWMyL35qr2dB+S0UgL2VzJKGuHh3FOZnd/g2D7NILZjdOTKtMD x3g0ZktwHP6ipw8teq1wEDJ7YO0x2xhe3cClNOtGzhkIvW32ms5YjwcvBY6NQvBU18 7GnQnVL7w1x0A== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 401916331D for ; Tue, 26 Jul 2022 14:46:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="UPMOmb+0"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id r1-20020a05600c35c100b003a326685e7cso778148wmq.1 for ; Tue, 26 Jul 2022 05:46:06 -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=h53DiA/UCvKsJUis2lWATuAAfe37Smke2YjB7DNAO+E=; b=UPMOmb+0h1IaBB25MTVD4TOW9NyHcblnCEbbT5nCXdzV4CtIaSxhbl0aZEq9OoX08E KXS+9DcEEfvt5xTkq8rNIPtUoE/VYx5p7L1FMxH/k8qJuG3x2s2qlGcOoh0nnz1tghwE nMLRoJnZ4p0ghsX7dKEYElNPdXZKHE1eaycF4LlM2Jc6qC0ePaEbD8jgxW5R2YIqODv2 wBmwSZT2okyf/wCjydno+cGp7Qxtj7PoUxB0Jw3gJyxX77KcSnGz+hDN2M9QyPdi5jIh BvPCfH9L5Y+J/RX0cq7dsPP79nRrxfc6Q5G/a6g6oUy83KNQQnEBOjXWJisbzlIO1kl0 +Y5Q== 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=h53DiA/UCvKsJUis2lWATuAAfe37Smke2YjB7DNAO+E=; b=J5P8pzcClcyyly3lZj9Y3t42VWiMwjLE6zRje5hjaw94vusufQT5LBXKJF5QSUYWvi fDS3UxcKQ7v5Zd+F1NqmwdecOEbfxjSPt9vqtTmBCNwGkZhwkhOUQJT8U0LhVFVVwmbg Rdqko+yJGOynTm9JmHnF2mlzgu8sDU/Y6+qG/mUutdw5FzXo0Yg6UTrAo8SHSL8awg2D jnhSRb0NizPR8lITpVr18GksGuRpYxzOcX3nuEFiS7dnf30NJm3dbo/sl+C0RLGvB7VN /rXsuq5reXRsm1ElNecdJG99Gw0zHmhoNaC83n2ZXtXEfKb66dMfQGTnqDueJJZESvlP 2WPA== X-Gm-Message-State: AJIora+vgcpsA5RRL80tKYw4D7ifgzUa23M2i06dY/xki+UfSadNYgem yJ7/T2cfy0mVEBV2YyVVok9B9+OnPZzkjw== X-Google-Smtp-Source: AGRyM1t+Pxr3VPnIXeJegdx14gPG+rYDf2iEgBmlEUCPKjSq53K1JafokmFyh/W/QRF8BySARhtvKA== X-Received: by 2002:a05:600c:4e0d:b0:3a3:bc7:e9ec with SMTP id b13-20020a05600c4e0d00b003a30bc7e9ecmr25186916wmq.167.1658839565280; Tue, 26 Jul 2022 05:46:05 -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.46.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:46:03 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:41 +0100 Message-Id: <20220726124549.1646-10-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 09/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 src/ipa/raspberrypi/controller/rps/[f|g|l]* 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/focus.cpp | 14 ++-- src/ipa/raspberrypi/controller/rpi/focus.hpp | 4 +- src/ipa/raspberrypi/controller/rpi/geq.cpp | 48 +++++++------- src/ipa/raspberrypi/controller/rpi/geq.hpp | 6 +- src/ipa/raspberrypi/controller/rpi/lux.cpp | 70 ++++++++++---------- src/ipa/raspberrypi/controller/rpi/lux.hpp | 22 +++--- 6 files changed, 81 insertions(+), 83 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/focus.cpp b/src/ipa/raspberrypi/controller/rpi/focus.cpp index a87ec802b964..90f36e58f28c 100644 --- a/src/ipa/raspberrypi/controller/rpi/focus.cpp +++ b/src/ipa/raspberrypi/controller/rpi/focus.cpp @@ -23,28 +23,28 @@ Focus::Focus(Controller *controller) { } -char const *Focus::Name() const +char const *Focus::name() const { return NAME; } -void Focus::Process(StatisticsPtr &stats, Metadata *image_metadata) +void Focus::process(StatisticsPtr &stats, Metadata *imageMetadata) { FocusStatus status; unsigned int i; for (i = 0; i < FOCUS_REGIONS; i++) - status.focus_measures[i] = stats->focus_stats[i].contrast_val[1][1] / 1000; + status.focusMeasures[i] = stats->focus_stats[i].contrast_val[1][1] / 1000; status.num = i; - image_metadata->Set("focus.status", status); + imageMetadata->set("focus.status", status); LOG(RPiFocus, Debug) << "Focus contrast measure: " - << (status.focus_measures[5] + status.focus_measures[6]) / 10; + << (status.focusMeasures[5] + status.focusMeasures[6]) / 10; } /* Register algorithm with the system. */ -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return new Focus(controller); } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/focus.hpp b/src/ipa/raspberrypi/controller/rpi/focus.hpp index 131b1d0f2fbf..a9207eb3cc23 100644 --- a/src/ipa/raspberrypi/controller/rpi/focus.hpp +++ b/src/ipa/raspberrypi/controller/rpi/focus.hpp @@ -21,8 +21,8 @@ class Focus : public Algorithm { public: Focus(Controller *controller); - char const *Name() const override; - void Process(StatisticsPtr &stats, Metadata *image_metadata) override; + char const *name() const override; + void process(StatisticsPtr &stats, Metadata *imageMetadata) override; }; } /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/geq.cpp b/src/ipa/raspberrypi/controller/rpi/geq.cpp index 4530cb75792c..0da5efdf3d3d 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.cpp +++ b/src/ipa/raspberrypi/controller/rpi/geq.cpp @@ -28,54 +28,52 @@ Geq::Geq(Controller *controller) { } -char const *Geq::Name() const +char const *Geq::name() const { return NAME; } -void Geq::Read(boost::property_tree::ptree const ¶ms) +void Geq::read(boost::property_tree::ptree const ¶ms) { config_.offset = params.get("offset", 0); config_.slope = params.get("slope", 0.0); if (config_.slope < 0.0 || config_.slope >= 1.0) throw std::runtime_error("Geq: bad slope value"); if (params.get_child_optional("strength")) - config_.strength.Read(params.get_child("strength")); + config_.strength.read(params.get_child("strength")); } -void Geq::Prepare(Metadata *image_metadata) +void Geq::prepare(Metadata *imageMetadata) { - LuxStatus lux_status = {}; - lux_status.lux = 400; - if (image_metadata->Get("lux.status", lux_status)) + LuxStatus luxStatus = {}; + luxStatus.lux = 400; + if (imageMetadata->get("lux.status", luxStatus)) LOG(RPiGeq, Warning) << "no lux data found"; - DeviceStatus device_status; - device_status.analogue_gain = 1.0; // in case not found - if (image_metadata->Get("device.status", device_status)) + DeviceStatus deviceStatus; + deviceStatus.analogueGain = 1.0; // in case not found + if (imageMetadata->get("device.status", deviceStatus)) LOG(RPiGeq, Warning) << "no device metadata - use analogue gain of 1x"; - GeqStatus geq_status = {}; - double strength = - config_.strength.Empty() + GeqStatus geqStatus = {}; + double strength = config_.strength.empty() ? 1.0 - : config_.strength.Eval(config_.strength.Domain().Clip( - lux_status.lux)); - strength *= device_status.analogue_gain; + : config_.strength.eval(config_.strength.domain().clip(luxStatus.lux)); + strength *= deviceStatus.analogueGain; double offset = config_.offset * strength; double slope = config_.slope * strength; - geq_status.offset = std::min(65535.0, std::max(0.0, offset)); - geq_status.slope = std::min(.99999, std::max(0.0, slope)); + geqStatus.offset = std::min(65535.0, std::max(0.0, offset)); + geqStatus.slope = std::min(.99999, std::max(0.0, slope)); LOG(RPiGeq, Debug) - << "offset " << geq_status.offset << " slope " - << geq_status.slope << " (analogue gain " - << device_status.analogue_gain << " lux " - << lux_status.lux << ")"; - image_metadata->Set("geq.status", geq_status); + << "offset " << geqStatus.offset << " slope " + << geqStatus.slope << " (analogue gain " + << deviceStatus.analogueGain << " lux " + << luxStatus.lux << ")"; + imageMetadata->set("geq.status", geqStatus); } // Register algorithm with the system. -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return (Algorithm *)new Geq(controller); } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/geq.hpp b/src/ipa/raspberrypi/controller/rpi/geq.hpp index 8ba3046b2a2b..bdbc55b2e2d9 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.hpp +++ b/src/ipa/raspberrypi/controller/rpi/geq.hpp @@ -23,9 +23,9 @@ class Geq : public Algorithm { public: Geq(Controller *controller); - char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; - void Prepare(Metadata *image_metadata) override; + char const *name() const override; + void read(boost::property_tree::ptree const ¶ms) override; + void prepare(Metadata *imageMetadata) override; private: GeqConfig config_; diff --git a/src/ipa/raspberrypi/controller/rpi/lux.cpp b/src/ipa/raspberrypi/controller/rpi/lux.cpp index 4d145b6ff0e9..739a3d533874 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -31,74 +31,74 @@ Lux::Lux(Controller *controller) status_.lux = 400; } -char const *Lux::Name() const +char const *Lux::name() const { return NAME; } -void Lux::Read(boost::property_tree::ptree const ¶ms) +void Lux::read(boost::property_tree::ptree const ¶ms) { - reference_shutter_speed_ = + referenceShutterSpeed_ = params.get("reference_shutter_speed") * 1.0us; - reference_gain_ = params.get("reference_gain"); - reference_aperture_ = params.get("reference_aperture", 1.0); - reference_Y_ = params.get("reference_Y"); - reference_lux_ = params.get("reference_lux"); - current_aperture_ = reference_aperture_; + referenceGain_ = params.get("reference_gain"); + referenceAperture_ = params.get("reference_aperture", 1.0); + referenceY_ = params.get("reference_Y"); + referenceLux_ = params.get("reference_lux"); + currentAperture_ = referenceAperture_; } -void Lux::SetCurrentAperture(double aperture) +void Lux::setCurrentAperture(double aperture) { - current_aperture_ = aperture; + currentAperture_ = aperture; } -void Lux::Prepare(Metadata *image_metadata) +void Lux::prepare(Metadata *imageMetadata) { std::unique_lock lock(mutex_); - image_metadata->Set("lux.status", status_); + imageMetadata->set("lux.status", status_); } -void Lux::Process(StatisticsPtr &stats, Metadata *image_metadata) +void Lux::process(StatisticsPtr &stats, Metadata *imageMetadata) { - DeviceStatus device_status; - if (image_metadata->Get("device.status", device_status) == 0) { - double current_gain = device_status.analogue_gain; - double current_aperture = device_status.aperture.value_or(current_aperture_); + DeviceStatus deviceStatus; + if (imageMetadata->get("device.status", deviceStatus) == 0) { + double currentGain = deviceStatus.analogueGain; + double currentAperture = deviceStatus.aperture.value_or(currentAperture_); uint64_t sum = 0; uint32_t num = 0; uint32_t *bin = stats->hist[0].g_hist; - const int num_bins = sizeof(stats->hist[0].g_hist) / - sizeof(stats->hist[0].g_hist[0]); - for (int i = 0; i < num_bins; i++) + const int numBins = sizeof(stats->hist[0].g_hist) / + sizeof(stats->hist[0].g_hist[0]); + for (int i = 0; i < numBins; i++) sum += bin[i] * (uint64_t)i, num += bin[i]; // add .5 to reflect the mid-points of bins - double current_Y = sum / (double)num + .5; - double gain_ratio = reference_gain_ / current_gain; - double shutter_speed_ratio = - reference_shutter_speed_ / device_status.shutter_speed; - double aperture_ratio = reference_aperture_ / current_aperture; - double Y_ratio = current_Y * (65536 / num_bins) / reference_Y_; - double estimated_lux = shutter_speed_ratio * gain_ratio * - aperture_ratio * aperture_ratio * - Y_ratio * reference_lux_; + double currentY = sum / (double)num + .5; + double gainRatio = referenceGain_ / currentGain; + double shutterSpeedRatio = + referenceShutterSpeed_ / deviceStatus.shutterSpeed; + double apertureRatio = referenceAperture_ / currentAperture; + double yRatio = currentY * (65536 / numBins) / referenceY_; + double estimatedLux = shutterSpeedRatio * gainRatio * + apertureRatio * apertureRatio * + yRatio * referenceLux_; LuxStatus status; - status.lux = estimated_lux; - status.aperture = current_aperture; - LOG(RPiLux, Debug) << ": estimated lux " << estimated_lux; + status.lux = estimatedLux; + status.aperture = currentAperture; + LOG(RPiLux, Debug) << ": estimated lux " << estimatedLux; { std::unique_lock lock(mutex_); status_ = status; } // Overwrite the metadata here as well, so that downstream // algorithms get the latest value. - image_metadata->Set("lux.status", status); + imageMetadata->set("lux.status", status); } else LOG(RPiLux, Warning) << ": no device metadata"; } // Register algorithm with the system. -static Algorithm *Create(Controller *controller) +static Algorithm *create(Controller *controller) { return (Algorithm *)new Lux(controller); } -static RegisterAlgorithm reg(NAME, &Create); +static RegisterAlgorithm reg(NAME, &create); diff --git a/src/ipa/raspberrypi/controller/rpi/lux.hpp b/src/ipa/raspberrypi/controller/rpi/lux.hpp index 3ebd35d1e382..bd49a409d402 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.hpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.hpp @@ -21,21 +21,21 @@ class Lux : public Algorithm { public: Lux(Controller *controller); - char const *Name() const override; - void Read(boost::property_tree::ptree const ¶ms) override; - void Prepare(Metadata *image_metadata) override; - void Process(StatisticsPtr &stats, Metadata *image_metadata) override; - void SetCurrentAperture(double aperture); + char const *name() const override; + void read(boost::property_tree::ptree const ¶ms) override; + void prepare(Metadata *imageMetadata) override; + void process(StatisticsPtr &stats, Metadata *imageMetadata) override; + void setCurrentAperture(double aperture); private: // These values define the conditions of the reference image, against // which we compare the new image. - libcamera::utils::Duration reference_shutter_speed_; - double reference_gain_; - double reference_aperture_; // units of 1/f - double reference_Y_; // out of 65536 - double reference_lux_; - double current_aperture_; + libcamera::utils::Duration referenceShutterSpeed_; + double referenceGain_; + double referenceAperture_; // units of 1/f + double referenceY_; // out of 65536 + double referenceLux_; + double currentAperture_; LuxStatus status_; std::mutex mutex_; }; From patchwork Tue Jul 26 12:45:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16783 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 46F2FC3275 for ; Tue, 26 Jul 2022 12:46:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 001DE63317; Tue, 26 Jul 2022 14:46:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839573; bh=M6ZE3o2fghoWtS4ji2W8K8UQeneQpm7E86273fbZMWM=; 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=29rk8gCUpxeW4X+CpFAYdRcadXGGvQYV4vCLieZLuaFqsSMHof97H8TCLSZMu5zYI jx4O3Ag3dCidcYrIIQRGizq4P4D9Y5g2G048VEZt0JT968QGUhEQrz9YV3cniF3ZdO +HQ/qaItghbJVIY3tLTX7bJv5zJjn/TyoOwwvrgVwfb51bdIRERvf+GZ47UjDWd2K2 yT5PpdS6ku9CYn/p4KGzGG9GvLHZiPdlRNcfAfapo6OdI1p8HEOtigK4lEYfTv/Eut CnjI9nmgP2LoKr7hpzg6MNeIDgySAhGYI3aIgeEsNmwR0fp/VahHYj4RxlvqoCYnbC opkeG41ffCc9g== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2414263311 for ; Tue, 26 Jul 2022 14:46:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="mLwFFv6g"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id d8so19898152wrp.6 for ; Tue, 26 Jul 2022 05:46:07 -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=lJV82aXpXJtQQMSUEO7LLuOfWPbkgSr4e+cMhnX5w9s=; b=mLwFFv6gtsZAvycScGx8ZwQSR05r320PD+xNjcE2fidRhne7wHHjOiftfq/EFHWJiH rG6gDaX+1k8Rr9A/nVF14VWpcfZBehEw4hWHmQKdqO5JcbkF7UicFeW7banAs8iRQmGn 9Z7TsAOMEN5tVHYBjAxIzpsfEFyb5WyA0KkuSwUbDTzZTybhpRmtC9VxsQwKu+FilUzj Drv5s577eLYyqnn2VGJ9XtuUPTuti7Y9KSuXIMVf7HVmj3G4QaC2nxi7H6OPFW6LSpkC ovqaRspdVtiu8JgqZ1cQ2V8+FQiYz1R6jYob30ZP5ipZ2CSjJPTXLm9Ctv9p30bm38fy HdoA== 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=lJV82aXpXJtQQMSUEO7LLuOfWPbkgSr4e+cMhnX5w9s=; b=16K4ICkJsvUCyyHUvLZqoThiDtPOKR0EqHOebCIPo1IEBXCyWo0TSQek85LOoPWxzj ylM/g/+nNULVnm4XyR+ktKGo3vHMQgwfRX73EiYE/N2rv3FuQoPJFgXO85EiYnVSCzlV 9+iN61+XkZ8TheCE25w2a9db//2cuLmDO12zU80630cAdUVyUraE7nxJqY25bly07sCZ C9wTTsy3fpnEoSWtOqIJ5VuUC9Go0BxZHjVXTHweT/unTlpNxU/oAAzw6Rx9L2cgvKbR Xaz/AftEsdRPDX1t8BflCmeoaTSTGP4rPUfoJddZpk5tifStrDoMdMQgtrHCCWqm05RP HrVw== X-Gm-Message-State: AJIora9uLew0CJIIMWzWsUkJ75GYSu/j1IawKesrmYO4ycnqtqyJwM1s GnMLQYUltuTNBsKpagGpfy2rQjLH5nI2Eg== X-Google-Smtp-Source: AGRyM1vBKuYvS2eNQQ01eQ75wOxrcUGIx8tnnl0Ds2G9cNGAS2v3LAMK3UpAbEMBFdWlz/zbxsoZug== X-Received: by 2002:a05:6000:38c:b0:21e:b38d:6bad with SMTP id u12-20020a056000038c00b0021eb38d6badmr1078426wrf.130.1658839566452; Tue, 26 Jul 2022 05:46:06 -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.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:46:05 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:42 +0100 Message-Id: <20220726124549.1646-11-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 10/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 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 | 38 ++++++++--------- src/ipa/raspberrypi/controller/rpi/noise.hpp | 14 +++---- src/ipa/raspberrypi/controller/rpi/sdn.cpp | 36 ++++++++-------- src/ipa/raspberrypi/controller/rpi/sdn.hpp | 10 ++--- .../raspberrypi/controller/rpi/sharpen.cpp | 42 +++++++++---------- .../raspberrypi/controller/rpi/sharpen.hpp | 14 +++---- 6 files changed, 78 insertions(+), 76 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/noise.cpp b/src/ipa/raspberrypi/controller/rpi/noise.cpp index 63cad639f313..97b0fd05e9d3 100644 --- a/src/ipa/raspberrypi/controller/rpi/noise.cpp +++ b/src/ipa/raspberrypi/controller/rpi/noise.cpp @@ -22,55 +22,55 @@ 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.noiseConstant = referenceConstant_ * factor; + status.noiseSlope = referenceSlope_ * factor; + imageMetadata->set("noise.status", status); LOG(RPiNoise, Debug) - << "constant " << status.noise_constant - << " slope " << status.noise_slope; + << "constant " << status.noiseConstant + << " slope " << status.noiseSlope; } else LOG(RPiNoise, Warning) << " no 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..480da38dc068 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.noiseSlope = 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.noiseConstant + << " slope " << noiseStatus.noiseSlope; struct DenoiseStatus status; - status.noise_constant = noise_status.noise_constant * deviation_; - status.noise_slope = noise_status.noise_slope * deviation_; + status.noiseConstant = noiseStatus.noiseConstant * deviation_; + status.noiseSlope = noiseStatus.noiseSlope * 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 + << "programmed constant " << status.noiseConstant + << " slope " << status.noiseSlope << " 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..3fe62bc8a5cf 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 + // The userStrength_ 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); + // pipeline, thus we use the modeFactor_ here. Also avoid + // 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 From patchwork Tue Jul 26 12:45:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16786 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 BBEC4C3275 for ; Tue, 26 Jul 2022 12:46:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7A00C6332F; Tue, 26 Jul 2022 14:46:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839577; bh=VX6s6quxfukWaI1dYZSVhJnOptyn5oT3YVT0J0FaRmQ=; 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=LogCY7Me5FWVMrxR/VBgaXUrFJgr1zIfmcignIzzY1RjBXkRlmUNAuCeoGQ2AvZYp /ZbfUv3wuV4i9OzUgW3fF4T1X9OnuZzY+/llwNqkcutva8dtdZ+4GoKH7n5IW/oWzR nPxM+KaqFOht8WVDMODRbMLVLhrj+Wxp6BPtSZ2EWoFW/eSbC/itESj64ONL6B9QEx PDZgxrIta6mBgZ2pYn7rG9MGJbneRW3bYH3qlX0H+GGd0obLXJoDnL+enN+XTavrEw 2Bi/f1INILyon2yQx/cTf9O1t1PgcxdosmkbfzfRXOI56JlLOZVggpGTP/4aYQDsLP aP1IRh3kxHVRA== Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 26A9B63321 for ; Tue, 26 Jul 2022 14:46:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Su8zfQG0"; dkim-atps=neutral Received: by mail-wr1-x436.google.com with SMTP id u5so19995427wrm.4 for ; Tue, 26 Jul 2022 05:46:12 -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=nhmuGLaxsHYVDqL9qwca+U1A0N4BAG5JZ8/vwhYXmts=; b=Su8zfQG0Tmg8MUY1pUmR50SeKUX/pS3PpuDAFm/Ss1QstWiKxRU3j9ti/7J55WyNsY lGekMFJ//UMuXQUIlULylfLULcQzBpTrRIxL+n3gr8jlIfWK9FPLGsij07W3ZQuUi/HR y47gdMXHDCwI6teag5u8X0oDQfUiKyhL+aO8d7/RM86NhAKgIQYB04MiJcqIFvSOfnN1 zXmkt+DsbzTBX9rSMYcq7ZSVs3HpTyanFTgQqqlJlIMW5sotxsCktuyw8uiQ5gdhRZu+ 2SW9avGvA8A4D6QNGmzSbp4QWVf1alBP8tWLDzFyXb8t8lqQeB20Jpmizqf+VSZ+Z2Cl 59fA== 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=nhmuGLaxsHYVDqL9qwca+U1A0N4BAG5JZ8/vwhYXmts=; b=QiaWbtpDWeBXHcJGWVzeGs+hNHTB+VKtI5na4qfEHBB6r/lN42y42ZbP33glFWorQs 5in9wOMSlmLKzlon6YTgv/sXXtx/SW2NLbSO0eyXEM5RXdaEY3ZxICUktLC4VhfwvvtT VWjdq85EgENr/PrKMFhHIX2YSBRG4J8Wtzz+r6EgMa3C60amXNjqSLB2PnoJk28O3Mw4 f987ouELVa8E3o01X/S1KNaftoXTmLIxihhpwXe2gCTUCBoedr9GsApcYVMwluCIqgeT DCDSwpdaTzEJBdVPvmmHBrO6jrg6T/n1G2M2ufYl/DEgv5L/m1J6XD3dU8aU33WR6ISs wq7Q== X-Gm-Message-State: AJIora+fhGZ72nv6+tKVhSQV9ngrOaiofW5NSonuw5qu6gGkok5zPz+I sJpdTqIbi8WVmw1LFvHXMlDNhMy+zIPucg== X-Google-Smtp-Source: AGRyM1t7SkPoA5fjeCp3T+InQwKPgERU4NZwTv84124ahP5/d8GIka8mOqQQn3CQpunky5zXvLV5cw== X-Received: by 2002:a05:6000:1681:b0:21e:66c5:2d3a with SMTP id y1-20020a056000168100b0021e66c52d3amr11509190wrd.615.1658839567741; Tue, 26 Jul 2022 05:46:07 -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.46.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:46:06 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:43 +0100 Message-Id: <20220726124549.1646-12-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 11/17] ipa: raspberrypi: Change to C style code comments 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" As part of the on-going refactor efforts for the source files in src/ipa/raspberrypi/, switch all C++ style comments to C style comments. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/cam_helper.hpp | 98 ++++--- .../raspberrypi/controller/agc_algorithm.hpp | 4 +- src/ipa/raspberrypi/controller/agc_status.h | 18 +- src/ipa/raspberrypi/controller/algorithm.cpp | 2 +- src/ipa/raspberrypi/controller/algorithm.hpp | 16 +- src/ipa/raspberrypi/controller/alsc_status.h | 6 +- .../raspberrypi/controller/awb_algorithm.hpp | 4 +- src/ipa/raspberrypi/controller/awb_status.h | 6 +- .../controller/black_level_status.h | 4 +- src/ipa/raspberrypi/controller/camera_mode.h | 30 +- .../raspberrypi/controller/ccm_algorithm.hpp | 4 +- src/ipa/raspberrypi/controller/ccm_status.h | 2 +- .../controller/contrast_algorithm.hpp | 4 +- .../raspberrypi/controller/contrast_status.h | 6 +- src/ipa/raspberrypi/controller/controller.cpp | 6 +- src/ipa/raspberrypi/controller/controller.hpp | 20 +- .../controller/denoise_algorithm.hpp | 4 +- .../raspberrypi/controller/denoise_status.h | 2 +- src/ipa/raspberrypi/controller/dpc_status.h | 4 +- src/ipa/raspberrypi/controller/focus_status.h | 8 +- src/ipa/raspberrypi/controller/geq_status.h | 2 +- src/ipa/raspberrypi/controller/histogram.cpp | 8 +- src/ipa/raspberrypi/controller/histogram.hpp | 18 +- src/ipa/raspberrypi/controller/lux_status.h | 18 +- src/ipa/raspberrypi/controller/metadata.hpp | 20 +- src/ipa/raspberrypi/controller/noise_status.h | 2 +- src/ipa/raspberrypi/controller/pwl.cpp | 40 ++- src/ipa/raspberrypi/controller/pwl.hpp | 60 ++-- src/ipa/raspberrypi/controller/rpi/agc.cpp | 269 +++++++++++------- src/ipa/raspberrypi/controller/rpi/agc.hpp | 24 +- src/ipa/raspberrypi/controller/rpi/alsc.cpp | 180 +++++++----- src/ipa/raspberrypi/controller/rpi/alsc.hpp | 50 ++-- src/ipa/raspberrypi/controller/rpi/awb.cpp | 192 ++++++++----- src/ipa/raspberrypi/controller/rpi/awb.hpp | 112 ++++---- .../controller/rpi/black_level.cpp | 10 +- .../controller/rpi/black_level.hpp | 4 +- src/ipa/raspberrypi/controller/rpi/ccm.cpp | 20 +- src/ipa/raspberrypi/controller/rpi/ccm.hpp | 4 +- .../raspberrypi/controller/rpi/contrast.cpp | 74 +++-- .../raspberrypi/controller/rpi/contrast.hpp | 8 +- src/ipa/raspberrypi/controller/rpi/dpc.cpp | 10 +- src/ipa/raspberrypi/controller/rpi/dpc.hpp | 4 +- src/ipa/raspberrypi/controller/rpi/geq.cpp | 10 +- src/ipa/raspberrypi/controller/rpi/geq.hpp | 6 +- src/ipa/raspberrypi/controller/rpi/lux.cpp | 16 +- src/ipa/raspberrypi/controller/rpi/lux.hpp | 14 +- src/ipa/raspberrypi/controller/rpi/noise.cpp | 24 +- src/ipa/raspberrypi/controller/rpi/noise.hpp | 6 +- src/ipa/raspberrypi/controller/rpi/sdn.cpp | 12 +- src/ipa/raspberrypi/controller/rpi/sdn.hpp | 4 +- .../raspberrypi/controller/rpi/sharpen.cpp | 32 ++- .../raspberrypi/controller/rpi/sharpen.hpp | 4 +- .../controller/sharpen_algorithm.hpp | 4 +- .../raspberrypi/controller/sharpen_status.h | 10 +- src/ipa/raspberrypi/md_parser.hpp | 2 +- 55 files changed, 890 insertions(+), 631 deletions(-) diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.hpp index 0cd718c4bc4e..2408fa154d3d 100644 --- a/src/ipa/raspberrypi/cam_helper.hpp +++ b/src/ipa/raspberrypi/cam_helper.hpp @@ -21,50 +21,52 @@ namespace RPiController { -// The CamHelper class provides a number of facilities that anyone trying -// to drive a camera will need to know, but which are not provided by the -// standard driver framework. Specifically, it provides: -// -// A "CameraMode" structure to describe extra information about the chosen -// mode of the driver. For example, how it is cropped from the full sensor -// area, how it is scaled, whether pixels are averaged compared to the full -// resolution. -// -// The ability to convert between number of lines of exposure and actual -// exposure time, and to convert between the sensor's gain codes and actual -// gains. -// -// A function to return the number of frames of delay between updating exposure, -// analogue gain and vblanking, and for the changes to take effect. For many -// sensors these take the values 2, 1 and 2 respectively, but sensors that are -// different will need to over-ride the default function provided. -// -// A function to query if the sensor outputs embedded data that can be parsed. -// -// A function to return the sensitivity of a given camera mode. -// -// A parser to parse the embedded data buffers provided by some sensors (for -// example, the imx219 does; the ov5647 doesn't). This allows us to know for -// sure the exposure and gain of the frame we're looking at. CamHelper -// provides functions for converting analogue gains to and from the sensor's -// native gain codes. -// -// Finally, a set of functions that determine how to handle the vagaries of -// different camera modules on start-up or when switching modes. Some -// modules may produce one or more frames that are not yet correctly exposed, -// or where the metadata may be suspect. We have the following functions: -// HideFramesStartup(): Tell the pipeline handler not to return this many -// frames at start-up. This can also be used to hide initial frames -// while the AGC and other algorithms are sorting themselves out. -// HideFramesModeSwitch(): Tell the pipeline handler not to return this -// many frames after a mode switch (other than start-up). Some sensors -// may produce innvalid frames after a mode switch; others may not. -// MistrustFramesStartup(): At start-up a sensor may return frames for -// which we should not run any control algorithms (for example, metadata -// may be invalid). -// MistrustFramesModeSwitch(): The number of frames, after a mode switch -// (other than start-up), for which control algorithms should not run -// (for example, metadata may be unreliable). +/* + * The CamHelper class provides a number of facilities that anyone trying + * to drive a camera will need to know, but which are not provided by the + * standard driver framework. Specifically, it provides: + * + * A "CameraMode" structure to describe extra information about the chosen + * mode of the driver. For example, how it is cropped from the full sensor + * area, how it is scaled, whether pixels are averaged compared to the full + * resolution. + * + * The ability to convert between number of lines of exposure and actual + * exposure time, and to convert between the sensor's gain codes and actual + * gains. + * + * A function to return the number of frames of delay between updating exposure, + * analogue gain and vblanking, and for the changes to take effect. For many + * sensors these take the values 2, 1 and 2 respectively, but sensors that are + * different will need to over-ride the default function provided. + * + * A function to query if the sensor outputs embedded data that can be parsed. + * + * A function to return the sensitivity of a given camera mode. + * + * A parser to parse the embedded data buffers provided by some sensors (for + * example, the imx219 does; the ov5647 doesn't). This allows us to know for + * sure the exposure and gain of the frame we're looking at. CamHelper + * provides functions for converting analogue gains to and from the sensor's + * native gain codes. + * + * Finally, a set of functions that determine how to handle the vagaries of + * different camera modules on start-up or when switching modes. Some + * modules may produce one or more frames that are not yet correctly exposed, + * or where the metadata may be suspect. We have the following functions: + * HideFramesStartup(): Tell the pipeline handler not to return this many + * frames at start-up. This can also be used to hide initial frames + * while the AGC and other algorithms are sorting themselves out. + * HideFramesModeSwitch(): Tell the pipeline handler not to return this + * many frames after a mode switch (other than start-up). Some sensors + * may produce innvalid frames after a mode switch; others may not. + * MistrustFramesStartup(): At start-up a sensor may return frames for + * which we should not run any control algorithms (for example, metadata + * may be invalid). + * MistrustFramesModeSwitch(): The number of frames, after a mode switch + * (other than start-up), for which control algorithms should not run + * (for example, metadata may be unreliable). + */ class CamHelper { @@ -110,8 +112,10 @@ private: unsigned int frameIntegrationDiff_; }; -// This is for registering camera helpers with the system, so that the -// CamHelper::Create function picks them up automatically. +/* + * This is for registering camera helpers with the system, so that the + * CamHelper::Create function picks them up automatically. + */ typedef CamHelper *(*CamHelperCreateFunc)(); struct RegisterCamHelper @@ -120,4 +124,4 @@ struct RegisterCamHelper CamHelperCreateFunc createFunc); }; -} // namespace RPi +} /* namespace RPi */ diff --git a/src/ipa/raspberrypi/controller/agc_algorithm.hpp b/src/ipa/raspberrypi/controller/agc_algorithm.hpp index 51900b687778..b718e595193b 100644 --- a/src/ipa/raspberrypi/controller/agc_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/agc_algorithm.hpp @@ -16,7 +16,7 @@ class AgcAlgorithm : public Algorithm { public: AgcAlgorithm(Controller *controller) : Algorithm(controller) {} - // An AGC algorithm must provide the following: + /* An AGC algorithm must provide the following: */ virtual unsigned int getConvergenceFrames() const = 0; virtual void setEv(double ev) = 0; virtual void setFlickerPeriod(libcamera::utils::Duration flickerPeriod) = 0; @@ -28,4 +28,4 @@ public: virtual void setConstraintMode(std::string const &contraintModeName) = 0; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/agc_status.h b/src/ipa/raspberrypi/controller/agc_status.h index d36b40d841db..9d184a158411 100644 --- a/src/ipa/raspberrypi/controller/agc_status.h +++ b/src/ipa/raspberrypi/controller/agc_status.h @@ -8,20 +8,24 @@ #include -// The AGC algorithm should post the following structure into the image's -// "agc.status" metadata. +/* + * The AGC algorithm should post the following structure into the image's + * "agc.status" metadata. + */ #ifdef __cplusplus extern "C" { #endif -// Note: total_exposure_value will be reported as zero until the algorithm has -// seen statistics and calculated meaningful values. The contents should be -// ignored until then. +/* + * Note: total_exposure_value will be reported as zero until the algorithm has + * seen statistics and calculated meaningful values. The contents should be + * ignored until then. + */ struct AgcStatus { - libcamera::utils::Duration totalExposureValue; // value for all exposure and gain for this image - libcamera::utils::Duration targetExposureValue; // (unfiltered) target total exposure AGC is aiming for + libcamera::utils::Duration totalExposureValue; /* value for all exposure and gain for this image */ + libcamera::utils::Duration targetExposureValue; /* (unfiltered) target total exposure AGC is aiming for */ libcamera::utils::Duration shutterTime; double analogueGain; char exposureMode[32]; diff --git a/src/ipa/raspberrypi/controller/algorithm.cpp b/src/ipa/raspberrypi/controller/algorithm.cpp index cfcd18a96c93..e3afa647bdd2 100644 --- a/src/ipa/raspberrypi/controller/algorithm.cpp +++ b/src/ipa/raspberrypi/controller/algorithm.cpp @@ -31,7 +31,7 @@ void Algorithm::process([[maybe_unused]] StatisticsPtr &stats, { } -// For registering algorithms with the system: +/* For registering algorithms with the system: */ static std::map algorithms; std::map const &RPiController::getAlgorithms() diff --git a/src/ipa/raspberrypi/controller/algorithm.hpp b/src/ipa/raspberrypi/controller/algorithm.hpp index a33b14da2726..cad7c15ba5c8 100644 --- a/src/ipa/raspberrypi/controller/algorithm.hpp +++ b/src/ipa/raspberrypi/controller/algorithm.hpp @@ -6,8 +6,10 @@ */ #pragma once -// All algorithms should be derived from this class and made available to the -// Controller. +/* + * All algorithms should be derived from this class and made available to the + * Controller. + */ #include #include @@ -19,7 +21,7 @@ namespace RPiController { -// This defines the basic interface for all control algorithms. +/* This defines the basic interface for all control algorithms. */ class Algorithm { @@ -48,8 +50,10 @@ private: bool paused_; }; -// This code is for automatic registration of Front End algorithms with the -// system. +/* + * This code is for automatic registration of Front End algorithms with the + * system. + */ typedef Algorithm *(*AlgoCreateFunc)(Controller *controller); struct RegisterAlgorithm { @@ -57,4 +61,4 @@ struct RegisterAlgorithm { }; std::map const &getAlgorithms(); -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/alsc_status.h b/src/ipa/raspberrypi/controller/alsc_status.h index d3f579715594..e074f9359faa 100644 --- a/src/ipa/raspberrypi/controller/alsc_status.h +++ b/src/ipa/raspberrypi/controller/alsc_status.h @@ -6,8 +6,10 @@ */ #pragma once -// The ALSC algorithm should post the following structure into the image's -// "alsc.status" metadata. +/* + * The ALSC algorithm should post the following structure into the image's + * "alsc.status" metadata. + */ #ifdef __cplusplus extern "C" { diff --git a/src/ipa/raspberrypi/controller/awb_algorithm.hpp b/src/ipa/raspberrypi/controller/awb_algorithm.hpp index c5d2ca90263c..0de74fce4269 100644 --- a/src/ipa/raspberrypi/controller/awb_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/awb_algorithm.hpp @@ -14,10 +14,10 @@ class AwbAlgorithm : public Algorithm { public: AwbAlgorithm(Controller *controller) : Algorithm(controller) {} - // An AWB algorithm must provide the following: + /* An AWB algorithm must provide the following: */ virtual unsigned int getConvergenceFrames() const = 0; virtual void setMode(std::string const &modeName) = 0; virtual void setManualGains(double manualR, double manualB) = 0; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/awb_status.h b/src/ipa/raspberrypi/controller/awb_status.h index bc428ed3206a..2f6e88ef6e7f 100644 --- a/src/ipa/raspberrypi/controller/awb_status.h +++ b/src/ipa/raspberrypi/controller/awb_status.h @@ -6,8 +6,10 @@ */ #pragma once -// The AWB algorithm places its results into both the image and global metadata, -// under the tag "awb.status". +/* + * The AWB algorithm places its results into both the image and global metadata, + * under the tag "awb.status". + */ #ifdef __cplusplus extern "C" { diff --git a/src/ipa/raspberrypi/controller/black_level_status.h b/src/ipa/raspberrypi/controller/black_level_status.h index df3661401d99..8b0523834dcf 100644 --- a/src/ipa/raspberrypi/controller/black_level_status.h +++ b/src/ipa/raspberrypi/controller/black_level_status.h @@ -6,14 +6,14 @@ */ #pragma once -// The "black level" algorithm stores the black levels to use. +/* The "black level" algorithm stores the black levels to use. */ #ifdef __cplusplus extern "C" { #endif struct BlackLevelStatus { - uint16_t blackLevelR; // out of 16 bits + uint16_t blackLevelR; /* out of 16 bits */ uint16_t blackLevelG; uint16_t blackLevelB; }; diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h index 8b81ca9df725..47a0fea424ca 100644 --- a/src/ipa/raspberrypi/controller/camera_mode.h +++ b/src/ipa/raspberrypi/controller/camera_mode.h @@ -10,9 +10,11 @@ #include -// Description of a "camera mode", holding enough information for control -// algorithms to adapt their behaviour to the different modes of the camera, -// including binning, scaling, cropping etc. +/* + * Description of a "camera mode", holding enough information for control + * algorithms to adapt their behaviour to the different modes of the camera, + * including binning, scaling, cropping etc. + */ #ifdef __cplusplus extern "C" { @@ -21,27 +23,27 @@ extern "C" { #define CAMERA_MODE_NAME_LEN 32 struct CameraMode { - // bit depth of the raw camera output + /* bit depth of the raw camera output */ uint32_t bitdepth; - // size in pixels of frames in this mode + /* size in pixels of frames in this mode */ uint16_t width, height; - // size of full resolution uncropped frame ("sensor frame") + /* size of full resolution uncropped frame ("sensor frame") */ uint16_t sensorWidth, sensorHeight; - // binning factor (1 = no binning, 2 = 2-pixel binning etc.) + /* binning factor (1 = no binning, 2 = 2-pixel binning etc.) */ uint8_t binX, binY; - // location of top left pixel in the sensor frame + /* location of top left pixel in the sensor frame */ uint16_t cropX, cropY; - // scaling factor (so if uncropped, width*scaleX is sensorWidth) + /* scaling factor (so if uncropped, width*scaleX is sensorWidth) */ double scaleX, scaleY; - // scaling of the noise compared to the native sensor mode + /* scaling of the noise compared to the native sensor mode */ double noiseFactor; - // line time + /* line time */ libcamera::utils::Duration lineLength; - // any camera transform *not* reflected already in the camera tuning + /* any camera transform *not* reflected already in the camera tuning */ libcamera::Transform transform; - // minimum and maximum fame lengths in units of lines + /* minimum and maximum fame lengths in units of lines */ uint32_t minFrameLength, maxFrameLength; - // sensitivity of this mode + /* 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 b8b5879ba99c..9c7172f5782d 100644 --- a/src/ipa/raspberrypi/controller/ccm_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/ccm_algorithm.hpp @@ -14,8 +14,8 @@ class CcmAlgorithm : public Algorithm { public: CcmAlgorithm(Controller *controller) : Algorithm(controller) {} - // A CCM algorithm must provide the following: + /* A CCM algorithm must provide the following: */ virtual void setSaturation(double saturation) = 0; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/ccm_status.h b/src/ipa/raspberrypi/controller/ccm_status.h index 7e41dd1ff3c0..4cdd8bed0311 100644 --- a/src/ipa/raspberrypi/controller/ccm_status.h +++ b/src/ipa/raspberrypi/controller/ccm_status.h @@ -6,7 +6,7 @@ */ #pragma once -// The "ccm" algorithm generates an appropriate colour matrix. +/* The "ccm" algorithm generates an appropriate colour matrix. */ #ifdef __cplusplus extern "C" { diff --git a/src/ipa/raspberrypi/controller/contrast_algorithm.hpp b/src/ipa/raspberrypi/controller/contrast_algorithm.hpp index c76f3cd759ba..1c0562e1c4a2 100644 --- a/src/ipa/raspberrypi/controller/contrast_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/contrast_algorithm.hpp @@ -14,9 +14,9 @@ class ContrastAlgorithm : public Algorithm { public: ContrastAlgorithm(Controller *controller) : Algorithm(controller) {} - // A contrast algorithm must provide the following: + /* A contrast algorithm must provide the following: */ virtual void setBrightness(double brightness) = 0; virtual void setContrast(double contrast) = 0; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/contrast_status.h b/src/ipa/raspberrypi/controller/contrast_status.h index d7edd4e9990d..5eb084f78e71 100644 --- a/src/ipa/raspberrypi/controller/contrast_status.h +++ b/src/ipa/raspberrypi/controller/contrast_status.h @@ -6,8 +6,10 @@ */ #pragma once -// The "contrast" algorithm creates a gamma curve, optionally doing a little bit -// of contrast stretching based on the AGC histogram. +/* + * The "contrast" algorithm creates a gamma curve, optionally doing a little bit + * of contrast stretching based on the AGC histogram. + */ #ifdef __cplusplus extern "C" { diff --git a/src/ipa/raspberrypi/controller/controller.cpp b/src/ipa/raspberrypi/controller/controller.cpp index e0b152c74384..6d95fa55d1e4 100644 --- a/src/ipa/raspberrypi/controller/controller.cpp +++ b/src/ipa/raspberrypi/controller/controller.cpp @@ -89,8 +89,10 @@ Metadata &Controller::getGlobalMetadata() 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. + /* + * The passed name must be the entire algorithm name, or must match the + * last part of it with a period (.) just before. + */ size_t nameLen = name.length(); for (auto &algo : algorithms_) { char const *algoName = algo->name(); diff --git a/src/ipa/raspberrypi/controller/controller.hpp b/src/ipa/raspberrypi/controller/controller.hpp index a5e1eb38ab9d..29b2e8f34826 100644 --- a/src/ipa/raspberrypi/controller/controller.hpp +++ b/src/ipa/raspberrypi/controller/controller.hpp @@ -6,9 +6,11 @@ */ #pragma once -// The Controller is simply a container for a collecting together a number of -// "control algorithms" (such as AWB etc.) and for running them all in a -// convenient manner. +/* + * The Controller is simply a container for a collecting together a number of + * "control algorithms" (such as AWB etc.) and for running them all in a + * convenient manner. + */ #include #include @@ -25,10 +27,12 @@ class Algorithm; typedef std::unique_ptr AlgorithmPtr; typedef std::shared_ptr StatisticsPtr; -// The Controller holds a pointer to some global_metadata, which is how -// different controllers and control algorithms within them can exchange -// information. The Prepare function returns a pointer to metadata for this -// specific image, and which should be passed on to the Process function. +/* + * The Controller holds a pointer to some global_metadata, which is how + * different controllers and control algorithms within them can exchange + * information. The Prepare function returns a pointer to metadata for this + * specific image, and which should be passed on to the Process function. + */ class Controller { @@ -51,4 +55,4 @@ protected: bool switchModeCalled_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/denoise_algorithm.hpp b/src/ipa/raspberrypi/controller/denoise_algorithm.hpp index 48de542ac4f3..7004fe55b41f 100644 --- a/src/ipa/raspberrypi/controller/denoise_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/denoise_algorithm.hpp @@ -16,8 +16,8 @@ class DenoiseAlgorithm : public Algorithm { public: DenoiseAlgorithm(Controller *controller) : Algorithm(controller) {} - // A Denoise algorithm must provide the following: + /* A Denoise algorithm must provide the following: */ virtual void setMode(DenoiseMode mode) = 0; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/denoise_status.h b/src/ipa/raspberrypi/controller/denoise_status.h index fe304d098253..c2d9c7301b19 100644 --- a/src/ipa/raspberrypi/controller/denoise_status.h +++ b/src/ipa/raspberrypi/controller/denoise_status.h @@ -6,7 +6,7 @@ */ #pragma once -// This stores the parameters required for Denoise. +/* This stores the parameters required for Denoise. */ #ifdef __cplusplus extern "C" { diff --git a/src/ipa/raspberrypi/controller/dpc_status.h b/src/ipa/raspberrypi/controller/dpc_status.h index a3ec2762573b..c99ad8c500a6 100644 --- a/src/ipa/raspberrypi/controller/dpc_status.h +++ b/src/ipa/raspberrypi/controller/dpc_status.h @@ -6,14 +6,14 @@ */ #pragma once -// The "DPC" algorithm sets defective pixel correction strength. +/* The "DPC" algorithm sets defective pixel correction strength. */ #ifdef __cplusplus extern "C" { #endif struct DpcStatus { - int strength; // 0 = "off", 1 = "normal", 2 = "strong" + int strength; /* 0 = "off", 1 = "normal", 2 = "strong" */ }; #ifdef __cplusplus diff --git a/src/ipa/raspberrypi/controller/focus_status.h b/src/ipa/raspberrypi/controller/focus_status.h index 656455100b45..c75795dc0621 100644 --- a/src/ipa/raspberrypi/controller/focus_status.h +++ b/src/ipa/raspberrypi/controller/focus_status.h @@ -8,9 +8,11 @@ #include -// The focus algorithm should post the following structure into the image's -// "focus.status" metadata. Recall that it's only reporting focus (contrast) -// measurements, it's not driving any kind of auto-focus algorithm! +/* + * The focus algorithm should post the following structure into the image's + * "focus.status" metadata. Recall that it's only reporting focus (contrast) + * measurements, it's not driving any kind of auto-focus algorithm! + */ #ifdef __cplusplus extern "C" { diff --git a/src/ipa/raspberrypi/controller/geq_status.h b/src/ipa/raspberrypi/controller/geq_status.h index 07fd5f0347ef..0ebb7ce71d5b 100644 --- a/src/ipa/raspberrypi/controller/geq_status.h +++ b/src/ipa/raspberrypi/controller/geq_status.h @@ -6,7 +6,7 @@ */ #pragma once -// The "GEQ" algorithm calculates the green equalisation thresholds +/* The "GEQ" algorithm calculates the green equalisation thresholds */ #ifdef __cplusplus extern "C" { diff --git a/src/ipa/raspberrypi/controller/histogram.cpp b/src/ipa/raspberrypi/controller/histogram.cpp index e865bef0057b..91a759b53d34 100644 --- a/src/ipa/raspberrypi/controller/histogram.cpp +++ b/src/ipa/raspberrypi/controller/histogram.cpp @@ -30,13 +30,13 @@ double Histogram::quantile(double q, int first, int last) const last = cumulative_.size() - 2; assert(first <= last); uint64_t items = q * total(); - while (first < last) // binary search to find the right bin + while (first < last) /* binary search to find the right bin */ { int middle = (first + last) / 2; if (cumulative_[middle + 1] > items) - last = middle; // between first and middle + last = middle; /* between first and middle */ else - first = middle + 1; // after middle + first = middle + 1; /* after middle */ } assert(items >= cumulative_[first] && items <= cumulative_[last + 1]); double frac = cumulative_[first + 1] == cumulative_[first] ? 0 @@ -59,6 +59,6 @@ double Histogram::interQuantileMean(double qLo, double qHi) const sumBinFreq += bin * freq; cumulFreq += freq; } - // add 0.5 to give an average for bin mid-points + /* add 0.5 to give an average for bin mid-points */ return sumBinFreq / cumulFreq + 0.5; } diff --git a/src/ipa/raspberrypi/controller/histogram.hpp b/src/ipa/raspberrypi/controller/histogram.hpp index 4ff5a56b0243..2ed8d9713764 100644 --- a/src/ipa/raspberrypi/controller/histogram.hpp +++ b/src/ipa/raspberrypi/controller/histogram.hpp @@ -10,8 +10,10 @@ #include #include -// A simple histogram class, for use in particular to find "quantiles" and -// averages between "quantiles". +/* + * A simple histogram class, for use in particular to find "quantiles" and + * averages between "quantiles". + */ namespace RPiController { @@ -29,16 +31,18 @@ public: } uint32_t bins() const { return cumulative_.size() - 1; } uint64_t total() const { return cumulative_[cumulative_.size() - 1]; } - // Cumulative frequency up to a (fractional) point in a bin. + /* Cumulative frequency up to a (fractional) point in a bin. */ uint64_t cumulativeFreq(double bin) const; - // Return the (fractional) bin of the point q (0 <= q <= 1) through the - // histogram. Optionally provide limits to help. + /* + * Return the (fractional) bin of the point q (0 <= q <= 1) through the + * histogram. Optionally provide limits to help. + */ double quantile(double q, int first = -1, int last = -1) const; - // Return the average histogram bin value between the two quantiles. + /* Return the average histogram bin value between the two quantiles. */ double interQuantileMean(double qLo, double qHi) const; private: std::vector cumulative_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/lux_status.h b/src/ipa/raspberrypi/controller/lux_status.h index 8ccfd933829b..c1134bec3694 100644 --- a/src/ipa/raspberrypi/controller/lux_status.h +++ b/src/ipa/raspberrypi/controller/lux_status.h @@ -6,14 +6,16 @@ */ #pragma once -// The "lux" algorithm looks at the (AGC) histogram statistics of the frame and -// estimates the current lux level of the scene. It does this by a simple ratio -// calculation comparing to a reference image that was taken in known conditions -// with known statistics and a properly measured lux level. There is a slight -// problem with aperture, in that it may be variable without the system knowing -// or being aware of it. In this case an external application may set a -// "current_aperture" value if it wishes, which would be used in place of the -// (presumably meaningless) value in the image metadata. +/* + * The "lux" algorithm looks at the (AGC) histogram statistics of the frame and + * estimates the current lux level of the scene. It does this by a simple ratio + * calculation comparing to a reference image that was taken in known conditions + * with known statistics and a properly measured lux level. There is a slight + * problem with aperture, in that it may be variable without the system knowing + * or being aware of it. In this case an external application may set a + * "current_aperture" value if it wishes, which would be used in place of the + * (presumably meaningless) value in the image metadata. + */ #ifdef __cplusplus extern "C" { diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.hpp index a79a67d42cce..9f73e61ef91f 100644 --- a/src/ipa/raspberrypi/controller/metadata.hpp +++ b/src/ipa/raspberrypi/controller/metadata.hpp @@ -6,7 +6,7 @@ */ #pragma once -// A simple class for carrying arbitrary metadata, for example about an image. +/* A simple class for carrying arbitrary metadata, for example about an image. */ #include #include @@ -81,8 +81,10 @@ public: template T *getLocked(std::string const &tag) { - // This allows in-place access to the Metadata contents, - // for which you should be holding the lock. + /* + * This allows in-place access to the Metadata contents, + * for which you should be holding the lock. + */ auto it = data_.find(tag); if (it == data_.end()) return nullptr; @@ -92,13 +94,15 @@ public: template void setLocked(std::string const &tag, T const &value) { - // Use this only if you're holding the lock yourself. + /* Use this only if you're holding the lock yourself. */ data_[tag] = value; } - // Note: use of (lowercase) lock and unlock means you can create scoped - // locks with the standard lock classes. - // e.g. std::lock_guard lock(metadata) + /* + * Note: use of (lowercase) lock and unlock means you can create scoped + * locks with the standard lock classes. + * e.g. std::lock_guard lock(metadata) + */ void lock() { mutex_.lock(); } void unlock() { mutex_.unlock(); } @@ -107,4 +111,4 @@ private: std::map data_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/noise_status.h b/src/ipa/raspberrypi/controller/noise_status.h index 358af4fe869b..689beed394a7 100644 --- a/src/ipa/raspberrypi/controller/noise_status.h +++ b/src/ipa/raspberrypi/controller/noise_status.h @@ -6,7 +6,7 @@ */ #pragma once -// The "noise" algorithm stores an estimate of the noise profile for this image. +/* The "noise" algorithm stores an estimate of the noise profile for this image. */ #ifdef __cplusplus extern "C" { diff --git a/src/ipa/raspberrypi/controller/pwl.cpp b/src/ipa/raspberrypi/controller/pwl.cpp index 24ff3ea34f5f..d93cd2016dcf 100644 --- a/src/ipa/raspberrypi/controller/pwl.cpp +++ b/src/ipa/raspberrypi/controller/pwl.cpp @@ -66,11 +66,15 @@ double Pwl::eval(double x, int *spanPtr, bool updateSpan) const int Pwl::findSpan(double x, int span) const { - // Pwls are generally small, so linear search may well be faster than - // binary, though could review this if large PWls start turning up. + /* + * Pwls are generally small, so linear search may well be faster than + * binary, though could review this if large PWls start turning up. + */ int lastSpan = points_.size() - 2; - // some algorithms may call us with span pointing directly at the last - // control point + /* + * some algorithms may call us with span pointing directly at the last + * control point + */ span = std::max(0, std::min(lastSpan, span)); while (span < lastSpan && x >= points_[span + 1].x) span++; @@ -87,7 +91,7 @@ Pwl::PerpType Pwl::invert(Point const &xy, Point &perp, int &span, for (span = span + 1; span < (int)points_.size() - 1; span++) { Point spanVec = points_[span + 1] - points_[span]; double t = ((xy - points_[span]) % spanVec) / spanVec.len2(); - if (t < -eps) // off the start of this span + if (t < -eps) /* off the start of this span */ { if (span == 0) { perp = points_[span]; @@ -96,14 +100,14 @@ Pwl::PerpType Pwl::invert(Point const &xy, Point &perp, int &span, perp = points_[span]; return PerpType::Vertex; } - } else if (t > 1 + eps) // off the end of this span + } else if (t > 1 + eps) /* off the end of this span */ { if (span == (int)points_.size() - 2) { perp = points_[span + 1]; return PerpType::End; } prevOffEnd = true; - } else // a true perpendicular + } else /* a true perpendicular */ { perp = points_[span] + spanVec * t; return PerpType::Perpendicular; @@ -133,9 +137,11 @@ Pwl Pwl::inverse(bool *trueInverse, const double eps) const neither = true; } - // This is not a proper inverse if we found ourselves putting points - // onto both ends of the inverse, or if there were points that couldn't - // go on either. + /* + * This is not a proper inverse if we found ourselves putting points + * onto both ends of the inverse, or if there were points that couldn't + * go on either. + */ if (trueInverse) *trueInverse = !(neither || (appended && prepended)); @@ -154,8 +160,10 @@ Pwl Pwl::compose(Pwl const &other, const double eps) const otherSpan + 1 < (int)other.points_.size() && points_[thisSpan + 1].y >= other.points_[otherSpan + 1].x + eps) { - // next control point in result will be where this - // function's y reaches the next span in other + /* + * next control point in result will be where this + * function's y reaches the next span in other + */ thisX = points_[thisSpan].x + (other.points_[otherSpan + 1].x - points_[thisSpan].y) * @@ -164,15 +172,17 @@ Pwl Pwl::compose(Pwl const &other, const double eps) const } else if (abs(dy) > eps && otherSpan > 0 && points_[thisSpan + 1].y <= other.points_[otherSpan - 1].x - eps) { - // next control point in result will be where this - // function's y reaches the previous span in other + /* + * next control point in result will be where this + * function's y reaches the previous span in other + */ thisX = points_[thisSpan].x + (other.points_[otherSpan + 1].x - points_[thisSpan].y) * dx / dy; thisY = other.points_[--otherSpan].x; } else { - // we stay in the same span in other + /* we stay in the same span in other */ thisSpan++; thisX = points_[thisSpan].x, thisY = points_[thisSpan].y; diff --git a/src/ipa/raspberrypi/controller/pwl.hpp b/src/ipa/raspberrypi/controller/pwl.hpp index 4a38d1df5a33..e409c966baa0 100644 --- a/src/ipa/raspberrypi/controller/pwl.hpp +++ b/src/ipa/raspberrypi/controller/pwl.hpp @@ -63,44 +63,56 @@ public: Interval domain() const; Interval range() const; bool empty() const; - // Evaluate Pwl, optionally supplying an initial guess for the - // "span". The "span" may be optionally be updated. If you want to know - // the "span" value but don't have an initial guess you can set it to - // -1. + /* + * Evaluate Pwl, optionally supplying an initial guess for the + * "span". The "span" may be optionally be updated. If you want to know + * the "span" value but don't have an initial guess you can set it to + * -1. + */ double eval(double x, int *spanPtr = nullptr, bool updateSpan = true) const; - // Find perpendicular closest to xy, starting from span+1 so you can - // call it repeatedly to check for multiple closest points (set span to - // -1 on the first call). Also returns "pseudo" perpendiculars; see - // PerpType enum. + /* + * Find perpendicular closest to xy, starting from span+1 so you can + * call it repeatedly to check for multiple closest points (set span to + * -1 on the first call). Also returns "pseudo" perpendiculars; see + * PerpType enum. + */ enum class PerpType { - None, // no perpendicular found - Start, // start of Pwl is closest point - End, // end of Pwl is closest point - Vertex, // vertex of Pwl is closest point - Perpendicular // true perpendicular found + None, /* no perpendicular found */ + Start, /* start of Pwl is closest point */ + End, /* end of Pwl is closest point */ + Vertex, /* vertex of Pwl is closest point */ + Perpendicular /* true perpendicular found */ }; PerpType invert(Point const &xy, Point &perp, int &span, const double eps = 1e-6) const; - // Compute the inverse function. Indicate if it is a proper (true) - // inverse, or only a best effort (e.g. input was non-monotonic). + /* + * Compute the inverse function. Indicate if it is a proper (true) + * inverse, or only a best effort (e.g. input was non-monotonic). + */ Pwl inverse(bool *trueInverse = nullptr, const double eps = 1e-6) const; - // Compose two Pwls together, doing "this" first and "other" after. + /* Compose two Pwls together, doing "this" first and "other" after. */ Pwl compose(Pwl const &other, const double eps = 1e-6) const; - // Apply function to (x,y) values at every control point. + /* Apply function to (x,y) values at every control point. */ void map(std::function f) const; - // Apply function to (x, y0, y1) values wherever either Pwl has a - // control point. + /* + * Apply function to (x, y0, y1) values wherever either Pwl has a + * control point. + */ static void map2(Pwl const &pwl0, Pwl const &pwl1, std::function f); - // Combine two Pwls, meaning we create a new Pwl where the y values are - // given by running f wherever either has a knot. + /* + * Combine two Pwls, meaning we create a new Pwl where the y values are + * given by running f wherever either has a knot. + */ static Pwl combine(Pwl const &pwl0, Pwl const &pwl1, std::function f, const double eps = 1e-6); - // Make "this" match (at least) the given domain. Any extension my be - // clipped or linear. + /* + * Make "this" match (at least) the given domain. Any extension my be + * clipped or linear. + */ void matchDomain(Interval const &domain, bool clip = true, const double eps = 1e-6); Pwl &operator*=(double d); @@ -111,4 +123,4 @@ private: std::vector points_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index 408ff9cf296d..d7effebb0490 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -28,7 +28,7 @@ LOG_DEFINE_CATEGORY(RPiAgc) #define NAME "rpi.agc" -#define PIPELINE_BITS 13 // seems to be a 13-bit pipeline +#define PIPELINE_BITS 13 /* seems to be a 13-bit pipeline */ void AgcMeteringMode::read(boost::property_tree::ptree const ¶ms) { @@ -150,7 +150,7 @@ void AgcConfig::read(boost::property_tree::ptree const ¶ms) convergenceFrames = params.get("convergence_frames", 6); fastReduceThreshold = params.get("fast_reduce_threshold", 0.4); baseEv = params.get("base_ev", 1.0); - // Start with quite a low value as ramping up is easier than ramping down. + /* Start with quite a low value as ramping up is easier than ramping down. */ defaultExposureTime = params.get("default_exposure_time", 1000) * 1us; defaultAnalogueGain = params.get("default_analogueGain", 1.0); } @@ -170,8 +170,10 @@ Agc::Agc(Controller *controller) maxShutter_(0s), fixedShutter_(0s), fixedAnalogueGain_(0.0) { memset(&awb_, 0, sizeof(awb_)); - // Setting status_.totalExposureValue_ to zero initially tells us - // it's not been calculated yet (i.e. Process hasn't yet run). + /* + * Setting status_.totalExposureValue_ to zero initially tells us + * it's not been calculated yet (i.e. Process hasn't yet run). + */ memset(&status_, 0, sizeof(status_)); status_.ev = ev_; } @@ -185,16 +187,18 @@ void Agc::read(boost::property_tree::ptree const ¶ms) { LOG(RPiAgc, Debug) << "Agc"; config_.read(params); - // Set the config's defaults (which are the first ones it read) as our - // current modes, until someone changes them. (they're all known to - // exist at this point) + /* + * Set the config's defaults (which are the first ones it read) as our + * current modes, until someone changes them. (they're all known to + * exist at this point) + */ meteringModeName_ = config_.defaultMeteringMode; meteringMode_ = &config_.meteringModes[meteringModeName_]; exposureModeName_ = config_.defaultExposureMode; exposureMode_ = &config_.exposureModes[exposureModeName_]; constraintModeName_ = config_.defaultConstraintMode; constraintMode_ = &config_.constraintModes[constraintModeName_]; - // Set up the "last shutter/gain" values, in case AGC starts "disabled". + /* Set up the "last shutter/gain" values, in case AGC starts "disabled". */ status_.shutterTime = config_.defaultExposureTime; status_.analogueGain = config_.defaultAnalogueGain; } @@ -218,8 +222,10 @@ void Agc::resume() unsigned int Agc::getConvergenceFrames() const { - // If shutter and gain have been explicitly set, there is no - // convergence to happen, so no need to drop any frames - return zero. + /* + * If shutter and gain have been explicitly set, there is no + * convergence to happen, so no need to drop any frames - return zero. + */ if (fixedShutter_ && fixedAnalogueGain_) return 0; else @@ -244,14 +250,14 @@ void Agc::setMaxShutter(Duration maxShutter) void Agc::setFixedShutter(Duration fixedShutter) { fixedShutter_ = fixedShutter; - // Set this in case someone calls Pause() straight after. + /* Set this in case someone calls Pause() straight after. */ status_.shutterTime = clipShutter(fixedShutter_); } void Agc::setFixedAnalogueGain(double fixedAnalogueGain) { fixedAnalogueGain_ = fixedAnalogueGain; - // Set this in case someone calls Pause() straight after. + /* Set this in case someone calls Pause() straight after. */ status_.analogueGain = fixedAnalogueGain; } @@ -280,30 +286,32 @@ void Agc::switchMode(CameraMode const &cameraMode, Duration fixedShutter = clipShutter(fixedShutter_); if (fixedShutter && fixedAnalogueGain_) { - // We're going to reset the algorithm here with these fixed values. + /* We're going to reset the algorithm here with these fixed values. */ fetchAwbStatus(metadata); double minColourGain = std::min({ awb_.gainR, awb_.gainG, awb_.gainB, 1.0 }); ASSERT(minColourGain != 0.0); - // This is the equivalent of computeTargetExposure and applyDigitalGain. + /* This is the equivalent of computeTargetExposure and applyDigitalGain. */ target_.totalExposureNoDG = fixedShutter_ * fixedAnalogueGain_; target_.totalExposure = target_.totalExposureNoDG / minColourGain; - // Equivalent of filterExposure. This resets any "history". + /* Equivalent of filterExposure. This resets any "history". */ filtered_ = target_; - // Equivalent of divideUpExposure. + /* Equivalent of divideUpExposure. */ filtered_.shutter = fixedShutter; filtered_.analogueGain = fixedAnalogueGain_; } else if (status_.totalExposureValue) { - // On a mode switch, various things could happen: - // - the exposure profile might change - // - a fixed exposure or gain might be set - // - the new mode's sensitivity might be different - // We cope with the last of these by scaling the target values. After - // that we just need to re-divide the exposure/gain according to the - // current exposure profile, which takes care of everything else. + /* + * On a mode switch, various things could happen: + * - the exposure profile might change + * - a fixed exposure or gain might be set + * - the new mode's sensitivity might be different + * We cope with the last of these by scaling the target values. After + * that we just need to re-divide the exposure/gain according to the + * current exposure profile, which takes care of everything else. + */ double ratio = lastSensitivity_ / cameraMode.sensitivity; target_.totalExposureNoDG *= ratio; @@ -313,29 +321,31 @@ void Agc::switchMode(CameraMode const &cameraMode, divideUpExposure(); } else { - // We come through here on startup, when at least one of the shutter - // or gain has not been fixed. We must still write those values out so - // that they will be applied immediately. We supply some arbitrary defaults - // for any that weren't set. - - // Equivalent of divideUpExposure. + /* + * We come through here on startup, when at least one of the shutter + * or gain has not been fixed. We must still write those values out so + * that they will be applied immediately. We supply some arbitrary defaults + * for any that weren't set. + */ + + /* Equivalent of divideUpExposure. */ filtered_.shutter = fixedShutter ? fixedShutter : config_.defaultExposureTime; filtered_.analogueGain = fixedAnalogueGain_ ? fixedAnalogueGain_ : config_.defaultAnalogueGain; } writeAndFinish(metadata, false); - // We must remember the sensitivity of this mode for the next SwitchMode. + /* We must remember the sensitivity of this mode for the next SwitchMode. */ lastSensitivity_ = cameraMode.sensitivity; } void Agc::prepare(Metadata *imageMetadata) { status_.digitalGain = 1.0; - fetchAwbStatus(imageMetadata); // always fetch it so that Process knows it's been done + fetchAwbStatus(imageMetadata); /* always fetch it so that Process knows it's been done */ if (status_.totalExposureValue) { - // Process has run, so we have meaningful values. + /* Process has run, so we have meaningful values. */ DeviceStatus deviceStatus; if (imageMetadata->get("device.status", deviceStatus) == 0) { Duration actualExposure = deviceStatus.shutterSpeed * @@ -343,14 +353,16 @@ void Agc::prepare(Metadata *imageMetadata) if (actualExposure) { status_.digitalGain = status_.totalExposureValue / actualExposure; LOG(RPiAgc, Debug) << "Want total exposure " << status_.totalExposureValue; - // Never ask for a gain < 1.0, and also impose - // some upper limit. Make it customisable? + /* + * Never ask for a gain < 1.0, and also impose + * some upper limit. Make it customisable? + */ status_.digitalGain = std::max(1.0, std::min(status_.digitalGain, 4.0)); LOG(RPiAgc, Debug) << "Actual exposure " << actualExposure; LOG(RPiAgc, Debug) << "Use digitalGain " << status_.digitalGain; LOG(RPiAgc, Debug) << "Effective exposure " << actualExposure * status_.digitalGain; - // Decide whether AEC/AGC has converged. + /* Decide whether AEC/AGC has converged. */ updateLockStatus(deviceStatus); } } else @@ -362,44 +374,52 @@ void Agc::prepare(Metadata *imageMetadata) void Agc::process(StatisticsPtr &stats, Metadata *imageMetadata) { frameCount_++; - // First a little bit of housekeeping, fetching up-to-date settings and - // configuration, that kind of thing. + /* + * First a little bit of housekeeping, fetching up-to-date settings and + * configuration, that kind of thing. + */ housekeepConfig(); - // Get the current exposure values for the frame that's just arrived. + /* Get the current exposure values for the frame that's just arrived. */ fetchCurrentExposure(imageMetadata); - // Compute the total gain we require relative to the current exposure. + /* Compute the total gain we require relative to the current exposure. */ double gain, targetY; computeGain(stats.get(), imageMetadata, gain, targetY); - // Now compute the target (final) exposure which we think we want. + /* Now compute the target (final) exposure which we think we want. */ computeTargetExposure(gain); - // Some of the exposure has to be applied as digital gain, so work out - // what that is. This function also tells us whether it's decided to - // "desaturate" the image more quickly. + /* + * Some of the exposure has to be applied as digital gain, so work out + * what that is. This function also tells us whether it's decided to + * "desaturate" the image more quickly. + */ bool desaturate = applyDigitalGain(gain, targetY); - // The results have to be filtered so as not to change too rapidly. + /* The results have to be filtered so as not to change too rapidly. */ filterExposure(desaturate); - // The last thing is to divide up the exposure value into a shutter time - // and analogue gain, according to the current exposure mode. + /* + * The last thing is to divide up the exposure value into a shutter time + * and analogue gain, according to the current exposure mode. + */ divideUpExposure(); - // Finally advertise what we've done. + /* Finally advertise what we've done. */ writeAndFinish(imageMetadata, desaturate); } void Agc::updateLockStatus(DeviceStatus const &deviceStatus) { - const double errorFactor = 0.10; // make these customisable? + const double errorFactor = 0.10; /* make these customisable? */ const int maxLockCount = 5; - // Reset "lock count" when we exceed this multiple of errorFactor + /* Reset "lock count" when we exceed this multiple of errorFactor */ const double resetMargin = 1.5; - // Add 200us to the exposure time error to allow for line quantisation. + /* Add 200us to the exposure time error to allow for line quantisation. */ Duration exposureError = lastDeviceStatus_.shutterSpeed * errorFactor + 200us; double gainError = lastDeviceStatus_.analogueGain * errorFactor; Duration targetError = lastTargetExposure_ * errorFactor; - // Note that we don't know the exposure/gain limits of the sensor, so - // the values we keep requesting may be unachievable. For this reason - // we only insist that we're close to values in the past few frames. + /* + * Note that we don't know the exposure/gain limits of the sensor, so + * the values we keep requesting may be unachievable. For this reason + * we only insist that we're close to values in the past few frames. + */ if (deviceStatus.shutterSpeed > lastDeviceStatus_.shutterSpeed - exposureError && deviceStatus.shutterSpeed < lastDeviceStatus_.shutterSpeed + exposureError && deviceStatus.analogueGain > lastDeviceStatus_.analogueGain - gainError && @@ -430,7 +450,7 @@ static void copyString(std::string const &s, char *d, size_t size) void Agc::housekeepConfig() { - // First fetch all the up-to-date settings, so no one else has to do it. + /* First fetch all the up-to-date settings, so no one else has to do it. */ status_.ev = ev_; status_.fixedShutter = clipShutter(fixedShutter_); status_.fixedAnalogueGain = fixedAnalogueGain_; @@ -438,8 +458,10 @@ void Agc::housekeepConfig() LOG(RPiAgc, Debug) << "ev " << status_.ev << " fixedShutter " << status_.fixedShutter << " fixedAnalogueGain " << status_.fixedAnalogueGain; - // Make sure the "mode" pointers point to the up-to-date things, if - // they've changed. + /* + * Make sure the "mode" pointers point to the up-to-date things, if + * they've changed. + */ if (strcmp(meteringModeName_.c_str(), status_.meteringMode)) { auto it = config_.meteringModes.find(meteringModeName_); if (it == config_.meteringModes.end()) @@ -491,7 +513,7 @@ void Agc::fetchCurrentExposure(Metadata *imageMetadata) void Agc::fetchAwbStatus(Metadata *imageMetadata) { - awb_.gainR = 1.0; // in case not found in metadata + awb_.gainR = 1.0; /* in case not found in metadata */ awb_.gainG = 1.0; awb_.gainB = 1.0; if (imageMetadata->get("awb.status", awb_) != 0) @@ -502,8 +524,10 @@ static double computeInitialY(bcm2835_isp_stats *stats, AwbStatus const &awb, double weights[], double gain) { bcm2835_isp_stats_region *regions = stats->agc_stats; - // Note how the calculation below means that equal weights give you - // "average" metering (i.e. all pixels equally important). + /* + * Note how the calculation below means that equal weights give you + * "average" metering (i.e. all pixels equally important). + */ double rSum = 0, gSum = 0, bSum = 0, pixelSum = 0; for (int i = 0; i < AGC_STATS_SIZE; i++) { double counted = regions[i].counted; @@ -525,11 +549,13 @@ static double computeInitialY(bcm2835_isp_stats *stats, AwbStatus const &awb, return ySum / pixelSum / (1 << PIPELINE_BITS); } -// We handle extra gain through EV by adjusting our Y targets. However, you -// simply can't monitor histograms once they get very close to (or beyond!) -// saturation, so we clamp the Y targets to this value. It does mean that EV -// increases don't necessarily do quite what you might expect in certain -// (contrived) cases. +/* + * We handle extra gain through EV by adjusting our Y targets. However, you + * simply can't monitor histograms once they get very close to (or beyond!) + * saturation, so we clamp the Y targets to this value. It does mean that EV + * increases don't necessarily do quite what you might expect in certain + * (contrived) cases. + */ #define EV_GAIN_Y_TARGET_LIMIT 0.9 @@ -546,18 +572,22 @@ void Agc::computeGain(bcm2835_isp_stats *statistics, Metadata *imageMetadata, double &gain, double &targetY) { struct LuxStatus lux = {}; - lux.lux = 400; // default lux level to 400 in case no metadata found + lux.lux = 400; /* default lux level to 400 in case no metadata found */ if (imageMetadata->get("lux.status", lux) != 0) LOG(RPiAgc, Warning) << "Agc: no lux level found"; Histogram h(statistics->hist[0].g_hist, NUM_HISTOGRAM_BINS); double evGain = status_.ev * config_.baseEv; - // The initial gain and target_Y come from some of the regions. After - // that we consider the histogram constraints. + /* + * The initial gain and target_Y come from some of the regions. After + * that we consider the histogram constraints. + */ targetY = config_.yTarget.eval(config_.yTarget.domain().clip(lux.lux)); targetY = std::min(EV_GAIN_Y_TARGET_LIMIT, targetY * evGain); - // Do this calculation a few times as brightness increase can be - // non-linear when there are saturated regions. + /* + * Do this calculation a few times as brightness increase can be + * non-linear when there are saturated regions. + */ gain = 1.0; for (int i = 0; i < 8; i++) { double initialY = computeInitialY(statistics, awb_, meteringMode_->weights, gain); @@ -565,7 +595,7 @@ void Agc::computeGain(bcm2835_isp_stats *statistics, Metadata *imageMetadata, gain *= extraGain; LOG(RPiAgc, Debug) << "Initial Y " << initialY << " target " << targetY << " gives gain " << gain; - if (extraGain < 1.01) // close enough + if (extraGain < 1.01) /* close enough */ break; } @@ -592,20 +622,23 @@ void Agc::computeGain(bcm2835_isp_stats *statistics, Metadata *imageMetadata, void Agc::computeTargetExposure(double gain) { if (status_.fixedShutter && status_.fixedAnalogueGain) { - // When ag and shutter are both fixed, we need to drive the - // total exposure so that we end up with a digital gain of at least - // 1/minColourGain. Otherwise we'd desaturate channels causing - // white to go cyan or magenta. + /* + * When ag and shutter are both fixed, we need to drive the + * total exposure so that we end up with a digital gain of at least + * 1/minColourGain. Otherwise we'd desaturate channels causing + * white to go cyan or magenta. + */ double minColourGain = std::min({ awb_.gainR, awb_.gainG, awb_.gainB, 1.0 }); ASSERT(minColourGain != 0.0); target_.totalExposure = status_.fixedShutter * status_.fixedAnalogueGain / minColourGain; } else { - // The statistics reflect the image without digital gain, so the final - // total exposure we're aiming for is: + /* + * The statistics reflect the image without digital gain, so the final + * total exposure we're aiming for is: + */ target_.totalExposure = current_.totalExposureNoDG * gain; - // The final target exposure is also limited to what the exposure - // mode allows. + /* The final target exposure is also limited to what the exposure mode allows. */ Duration maxShutter = status_.fixedShutter ? status_.fixedShutter : exposureMode_->shutter.back(); @@ -625,17 +658,21 @@ bool Agc::applyDigitalGain(double gain, double targetY) double minColourGain = std::min({ awb_.gainR, awb_.gainG, awb_.gainB, 1.0 }); ASSERT(minColourGain != 0.0); double dg = 1.0 / minColourGain; - // I think this pipeline subtracts black level and rescales before we - // get the stats, so no need to worry about it. + /* + * I think this pipeline subtracts black level and rescales before we + * get the stats, so no need to worry about it. + */ LOG(RPiAgc, Debug) << "after AWB, target dg " << dg << " gain " << gain << " target_Y " << targetY; - // Finally, if we're trying to reduce exposure but the target_Y is - // "close" to 1.0, then the gain computed for that constraint will be - // only slightly less than one, because the measured Y can never be - // larger than 1.0. When this happens, demand a large digital gain so - // that the exposure can be reduced, de-saturating the image much more - // quickly (and we then approach the correct value more quickly from - // below). + /* + * Finally, if we're trying to reduce exposure but the target_Y is + * "close" to 1.0, then the gain computed for that constraint will be + * only slightly less than one, because the measured Y can never be + * larger than 1.0. When this happens, demand a large digital gain so + * that the exposure can be reduced, de-saturating the image much more + * quickly (and we then approach the correct value more quickly from + * below). + */ bool desaturate = targetY > config_.fastReduceThreshold && gain < sqrt(targetY); if (desaturate) @@ -649,8 +686,10 @@ bool Agc::applyDigitalGain(double gain, double targetY) void Agc::filterExposure(bool desaturate) { double speed = config_.speed; - // AGC adapts instantly if both shutter and gain are directly specified - // or we're in the startup phase. + /* + * AGC adapts instantly if both shutter and gain are directly specified + * or we're in the startup phase. + */ if ((status_.fixedShutter && status_.fixedAnalogueGain) || frameCount_ <= config_.startupFrames) speed = 1.0; @@ -658,15 +697,19 @@ void Agc::filterExposure(bool desaturate) filtered_.totalExposure = target_.totalExposure; filtered_.totalExposureNoDG = target_.totalExposureNoDG; } else { - // If close to the result go faster, to save making so many - // micro-adjustments on the way. (Make this customisable?) + /* + * If close to the result go faster, to save making so many + * micro-adjustments on the way. (Make this customisable?) + */ if (filtered_.totalExposure < 1.2 * target_.totalExposure && filtered_.totalExposure > 0.8 * target_.totalExposure) speed = sqrt(speed); filtered_.totalExposure = speed * target_.totalExposure + filtered_.totalExposure * (1.0 - speed); - // When desaturing, take a big jump down in totalExposureNoDG, - // which we'll hide with digital gain. + /* + * When desaturing, take a big jump down in totalExposureNoDG, + * which we'll hide with digital gain. + */ if (desaturate) filtered_.totalExposureNoDG = target_.totalExposureNoDG; @@ -675,9 +718,11 @@ void Agc::filterExposure(bool desaturate) speed * target_.totalExposureNoDG + filtered_.totalExposureNoDG * (1.0 - speed); } - // We can't let the totalExposureNoDG exposure deviate too far below the - // total exposure, as there might not be enough digital gain available - // in the ISP to hide it (which will cause nasty oscillation). + /* + * We can't let the totalExposureNoDG exposure deviate too far below the + * total exposure, as there might not be enough digital gain available + * in the ISP to hide it (which will cause nasty oscillation). + */ if (filtered_.totalExposureNoDG < filtered_.totalExposure * config_.fastReduceThreshold) filtered_.totalExposureNoDG = filtered_.totalExposure * config_.fastReduceThreshold; @@ -687,9 +732,11 @@ void Agc::filterExposure(bool desaturate) void Agc::divideUpExposure() { - // Sending the fixed shutter/gain cases through the same code may seem - // unnecessary, but it will make more sense when extend this to cover - // variable aperture. + /* + * Sending the fixed shutter/gain cases through the same code may seem + * unnecessary, but it will make more sense when extend this to cover + * variable aperture. + */ Duration exposureValue = filtered_.totalExposureNoDG; Duration shutterTime; double analogueGain; @@ -721,18 +768,22 @@ void Agc::divideUpExposure() } LOG(RPiAgc, Debug) << "Divided up shutter and gain are " << shutterTime << " and " << analogueGain; - // Finally adjust shutter time for flicker avoidance (require both - // shutter and gain not to be fixed). + /* + * Finally adjust shutter time for flicker avoidance (require both + * shutter and gain not to be fixed). + */ if (!status_.fixedShutter && !status_.fixedAnalogueGain && status_.flickerPeriod) { int flickerPeriods = shutterTime / status_.flickerPeriod; if (flickerPeriods) { Duration newShutterTime = flickerPeriods * status_.flickerPeriod; analogueGain *= shutterTime / newShutterTime; - // We should still not allow the ag to go over the - // largest value in the exposure mode. Note that this - // may force more of the total exposure into the digital - // gain as a side-effect. + /* + * We should still not allow the ag to go over the + * largest value in the exposure mode. Note that this + * may force more of the total exposure into the digital + * gain as a side-effect. + */ analogueGain = std::min(analogueGain, exposureMode_->gain.back()); shutterTime = newShutterTime; } @@ -749,8 +800,10 @@ void Agc::writeAndFinish(Metadata *imageMetadata, bool desaturate) status_.targetExposureValue = desaturate ? 0s : target_.totalExposureNoDG; status_.shutterTime = filtered_.shutter; status_.analogueGain = filtered_.analogueGain; - // Write to metadata as well, in case anyone wants to update the camera - // immediately. + /* + * Write to metadata as well, in case anyone wants to update the camera + * immediately. + */ imageMetadata->set("agc.status", status_); LOG(RPiAgc, Debug) << "Output written, total exposure requested is " << filtered_.totalExposure; @@ -765,7 +818,7 @@ Duration Agc::clipShutter(Duration shutter) return shutter; } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return (Algorithm *)new Agc(controller); diff --git a/src/ipa/raspberrypi/controller/rpi/agc.hpp b/src/ipa/raspberrypi/controller/rpi/agc.hpp index 4ed7293bce97..c2d68b60f15e 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.hpp @@ -15,10 +15,12 @@ #include "../agc_status.h" #include "../pwl.hpp" -// This is our implementation of AGC. +/* This is our implementation of AGC. */ -// This is the number actually set up by the firmware, not the maximum possible -// number (which is 16). +/* + * This is the number actually set up by the firmware, not the maximum possible + * number (which is 16). + */ #define AGC_STATS_SIZE 15 @@ -73,7 +75,7 @@ public: Agc(Controller *controller); char const *name() const override; void read(boost::property_tree::ptree const ¶ms) override; - // AGC handles "pausing" for itself. + /* AGC handles "pausing" for itself. */ bool isPaused() const override; void pause() override; void resume() override; @@ -115,17 +117,17 @@ private: libcamera::utils::Duration shutter; double analogueGain; libcamera::utils::Duration totalExposure; - libcamera::utils::Duration totalExposureNoDG; // without digital gain + libcamera::utils::Duration totalExposureNoDG; /* without digital gain */ }; - ExposureValues current_; // values for the current frame - ExposureValues target_; // calculate the values we want here - ExposureValues filtered_; // these values are filtered towards target + ExposureValues current_; /* values for the current frame */ + ExposureValues target_; /* calculate the values we want here */ + ExposureValues filtered_; /* these values are filtered towards target */ AgcStatus status_; int lockCount_; DeviceStatus lastDeviceStatus_; libcamera::utils::Duration lastTargetExposure_; - double lastSensitivity_; // sensitivity of the previous camera mode - // Below here the "settings" that applications can change. + double lastSensitivity_; /* sensitivity of the previous camera mode */ + /* Below here the "settings" that applications can change. */ std::string meteringModeName_; std::string exposureModeName_; std::string constraintModeName_; @@ -136,4 +138,4 @@ private: double fixedAnalogueGain_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp index 98b771542d95..6fd95a312411 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp @@ -14,7 +14,7 @@ #include "../awb_status.h" #include "alsc.hpp" -// Raspberry Pi ALSC (Auto Lens Shading Correction) algorithm. +/* Raspberry Pi ALSC (Auto Lens Shading Correction) algorithm. */ using namespace RPiController; using namespace libcamera; @@ -68,7 +68,7 @@ static void generateLut(double *lut, boost::property_tree::ptree const ¶ms) double r2 = (dx * dx + dy * dy) / R2; lut[num++] = (f1 * r2 + f2) * (f1 * r2 + f2) / - (f2 * f2); // this reproduces the cos^4 rule + (f2 * f2); /* this reproduces the cos^4 rule */ } } } @@ -171,7 +171,7 @@ void Alsc::initialise() frameCount2_ = frameCount_ = framePhase_ = 0; firstTime_ = true; ct_ = config_.defaultCt; - // The lambdas are initialised in the SwitchMode. + /* The lambdas are initialised in the SwitchMode. */ } void Alsc::waitForAysncThread() @@ -188,8 +188,10 @@ void Alsc::waitForAysncThread() static bool compareModes(CameraMode const &cm0, CameraMode const &cm1) { - // Return true if the modes crop from the sensor significantly differently, - // or if the user transform has changed. + /* + * Return true if the modes crop from the sensor significantly differently, + * or if the user transform has changed. + */ if (cm0.transform != cm1.transform) return true; int leftDiff = abs(cm0.cropX - cm1.cropX); @@ -198,9 +200,11 @@ static bool compareModes(CameraMode const &cm0, CameraMode const &cm1) cm1.cropX - cm1.scaleX * cm1.width); int bottomDiff = fabs(cm0.cropY + cm0.scaleY * cm0.height - cm1.cropY - cm1.scaleY * cm1.height); - // These thresholds are a rather arbitrary amount chosen to trigger - // when carrying on with the previously calculated tables might be - // worse than regenerating them (but without the adaptive algorithm). + /* + * These thresholds are a rather arbitrary amount chosen to trigger + * when carrying on with the previously calculated tables might be + * worse than regenerating them (but without the adaptive algorithm). + */ int thresholdX = cm0.sensorWidth >> 4; int thresholdY = cm0.sensorHeight >> 4; return leftDiff > thresholdX || rightDiff > thresholdX || @@ -210,28 +214,34 @@ static bool compareModes(CameraMode const &cm0, CameraMode const &cm1) void Alsc::switchMode(CameraMode const &cameraMode, [[maybe_unused]] Metadata *metadata) { - // We're going to start over with the tables if there's any "significant" - // change. + /* + * We're going to start over with the tables if there's any "significant" + * change. + */ bool resetTables = firstTime_ || compareModes(cameraMode_, cameraMode); - // Believe the colour temperature from the AWB, if there is one. + /* Believe the colour temperature from the AWB, if there is one. */ ct_ = getCt(metadata, ct_); - // Ensure the other thread isn't running while we do this. + /* Ensure the other thread isn't running while we do this. */ waitForAysncThread(); cameraMode_ = cameraMode; - // We must resample the luminance table like we do the others, but it's - // fixed so we can simply do it up front here. + /* + * We must resample the luminance table like we do the others, but it's + * fixed so we can simply do it up front here. + */ resampleCalTable(config_.luminanceLut, cameraMode_, luminanceTable_); if (resetTables) { - // Upon every "table reset", arrange for something sensible to be - // generated. Construct the tables for the previous recorded colour - // temperature. In order to start over from scratch we initialise - // the lambdas, but the rest of this code then echoes the code in - // doAlsc, without the adaptive algorithm. + /* + * Upon every "table reset", arrange for something sensible to be + * generated. Construct the tables for the previous recorded colour + * temperature. In order to start over from scratch we initialise + * the lambdas, but the rest of this code then echoes the code in + * doAlsc, without the adaptive algorithm. + */ for (int i = 0; i < XY; i++) lambdaR_[i] = lambdaB_[i] = 1.0; double calTableR[XY], calTableB[XY], calTableTmp[XY]; @@ -244,7 +254,7 @@ void Alsc::switchMode(CameraMode const &cameraMode, addLuminanceToTables(syncResults_, asyncLambdaR_, 1.0, asyncLambdaB_, luminanceTable_, config_.luminanceStrength); memcpy(prevSyncResults_, syncResults_, sizeof(prevSyncResults_)); - framePhase_ = config_.framePeriod; // run the algo again asap + framePhase_ = config_.framePeriod; /* run the algo again asap */ firstTime_ = false; } } @@ -260,7 +270,7 @@ void Alsc::fetchAsyncResults() double getCt(Metadata *metadata, double defaultCt) { AwbStatus awbStatus; - awbStatus.temperatureK = defaultCt; // in case nothing found + awbStatus.temperatureK = defaultCt; /* in case nothing found */ if (metadata->get("awb.status", awbStatus) != 0) LOG(RPiAlsc, Debug) << "no AWB results found, using " << awbStatus.temperatureK; @@ -282,18 +292,22 @@ static void copyStats(bcm2835_isp_stats_region regions[XY], StatisticsPtr &stats regions[i].g_sum = inputRegions[i].g_sum / gTable[i]; regions[i].b_sum = inputRegions[i].b_sum / bTable[i]; regions[i].counted = inputRegions[i].counted; - // (don't care about the uncounted value) + /* (don't care about the uncounted value) */ } } void Alsc::restartAsync(StatisticsPtr &stats, Metadata *imageMetadata) { LOG(RPiAlsc, Debug) << "Starting ALSC calculation"; - // Get the current colour temperature. It's all we need from the - // metadata. Default to the last CT value (which could be the default). + /* + * Get the current colour temperature. It's all we need from the + * metadata. Default to the last CT value (which could be the default). + */ ct_ = getCt(imageMetadata, ct_); - // We have to copy the statistics here, dividing out our best guess of - // the LSC table that the pipeline applied to them. + /* + * We have to copy the statistics here, dividing out our best guess of + * the LSC table that the pipeline applied to them. + */ AlscStatus alscStatus; if (imageMetadata->get("alsc.status", alscStatus) != 0) { LOG(RPiAlsc, Warning) @@ -317,8 +331,10 @@ void Alsc::restartAsync(StatisticsPtr &stats, Metadata *imageMetadata) void Alsc::prepare(Metadata *imageMetadata) { - // Count frames since we started, and since we last poked the async - // thread. + /* + * Count frames since we started, and since we last poked the async + * thread. + */ if (frameCount_ < (int)config_.startupFrames) frameCount_++; double speed = frameCount_ < (int)config_.startupFrames @@ -331,12 +347,12 @@ void Alsc::prepare(Metadata *imageMetadata) if (asyncStarted_ && asyncFinished_) fetchAsyncResults(); } - // Apply IIR filter to results and program into the pipeline. + /* Apply IIR filter to results and program into the pipeline. */ double *ptr = (double *)syncResults_, *pptr = (double *)prevSyncResults_; for (unsigned int i = 0; i < sizeof(syncResults_) / sizeof(double); i++) pptr[i] = speed * ptr[i] + (1.0 - speed) * pptr[i]; - // Put output values into status metadata. + /* Put output values into status metadata. */ AlscStatus status; memcpy(status.r, prevSyncResults_[0], sizeof(status.r)); memcpy(status.g, prevSyncResults_[1], sizeof(status.g)); @@ -346,8 +362,10 @@ void Alsc::prepare(Metadata *imageMetadata) void Alsc::process(StatisticsPtr &stats, Metadata *imageMetadata) { - // Count frames since we started, and since we last poked the async - // thread. + /* + * Count frames since we started, and since we last poked the async + * thread. + */ if (framePhase_ < (int)config_.framePeriod) framePhase_++; if (frameCount2_ < (int)config_.startupFrames) @@ -415,8 +433,10 @@ void getCalTable(double ct, std::vector const &calibrations, void resampleCalTable(double const calTableIn[XY], CameraMode const &cameraMode, double calTableOut[XY]) { - // Precalculate and cache the x sampling locations and phases to save - // recomputing them on every row. + /* + * Precalculate and cache the x sampling locations and phases to save + * recomputing them on every row. + */ int xLo[X], xHi[X]; double xf[X]; double scaleX = cameraMode.sensorWidth / @@ -434,7 +454,7 @@ void resampleCalTable(double const calTableIn[XY], xHi[i] = X - 1 - xHi[i]; } } - // Now march over the output table generating the new values. + /* Now march over the output table generating the new values. */ double scaleY = cameraMode.sensorHeight / (cameraMode.height * cameraMode.scaleY); double yOff = cameraMode.cropY / (double)cameraMode.sensorHeight; @@ -461,7 +481,7 @@ void resampleCalTable(double const calTableIn[XY], } } -// Calculate chrominance statistics (R/G and B/G) for each region. +/* Calculate chrominance statistics (R/G and B/G) for each region. */ static_assert(XY == AWB_REGIONS, "ALSC/AWB statistics region mismatch"); static void calculateCrCb(bcm2835_isp_stats_region *awbRegion, double cr[XY], double cb[XY], uint32_t minCount, uint16_t minG) @@ -512,8 +532,10 @@ void compensateLambdasForCal(double const calTable[XY], printf("]\n"); } -// Compute weight out of 1.0 which reflects how similar we wish to make the -// colours of these two regions. +/* + * Compute weight out of 1.0 which reflects how similar we wish to make the + * colours of these two regions. + */ static double computeWeight(double Ci, double Cj, double sigma) { if (Ci == InsufficientData || Cj == InsufficientData) @@ -522,11 +544,11 @@ static double computeWeight(double Ci, double Cj, double sigma) return exp(-diff * diff / 2); } -// Compute all weights. +/* Compute all weights. */ static void computeW(double const C[XY], double sigma, double W[XY][4]) { for (int i = 0; i < XY; i++) { - // Start with neighbour above and go clockwise. + /* Start with neighbour above and go clockwise. */ W[i][0] = i >= X ? computeWeight(C[i], C[i - X], sigma) : 0; W[i][1] = i % X < X - 1 ? computeWeight(C[i], C[i + 1], sigma) : 0; W[i][2] = i < XY - X ? computeWeight(C[i], C[i + X], sigma) : 0; @@ -534,17 +556,19 @@ static void computeW(double const C[XY], double sigma, double W[XY][4]) } } -// Compute M, the large but sparse matrix such that M * lambdas = 0. +/* Compute M, the large but sparse matrix such that M * lambdas = 0. */ static void constructM(double const C[XY], double const W[XY][4], double M[XY][4]) { double epsilon = 0.001; for (int i = 0; i < XY; i++) { - // Note how, if C[i] == INSUFFICIENT_DATA, the weights will all - // be zero so the equation is still set up correctly. + /* + * Note how, if C[i] == INSUFFICIENT_DATA, the weights will all + * be zero so the equation is still set up correctly. + */ int m = !!(i >= X) + !!(i % X < X - 1) + !!(i < XY - X) + - !!(i % X); // total number of neighbours - // we'll divide the diagonal out straight away + !!(i % X); /* total number of neighbours */ + /* we'll divide the diagonal out straight away */ double diagonal = (epsilon + W[i][0] + W[i][1] + W[i][2] + W[i][3]) * C[i]; M[i][0] = i >= X ? (W[i][0] * C[i - X] + epsilon / m * C[i]) / diagonal : 0; M[i][1] = i % X < X - 1 ? (W[i][1] * C[i + 1] + epsilon / m * C[i]) / diagonal : 0; @@ -553,9 +577,11 @@ static void constructM(double const C[XY], double const W[XY][4], } } -// In the compute_lambda_ functions, note that the matrix coefficients for the -// left/right neighbours are zero down the left/right edges, so we don't need -// need to test the i value to exclude them. +/* + * In the compute_lambda_ functions, note that the matrix coefficients for the + * left/right neighbours are zero down the left/right edges, so we don't need + * need to test the i value to exclude them. + */ static double computeLambdaBottom(int i, double const M[XY][4], double lambda[XY]) { @@ -585,7 +611,7 @@ static double computeLambdaTopEnd(int i, double const M[XY][4], return M[i][0] * lambda[i - X] + M[i][3] * lambda[i - 1]; } -// Gauss-Seidel iteration with over-relaxation. +/* Gauss-Seidel iteration with over-relaxation. */ static double gaussSeidel2Sor(double const M[XY][4], double omega, double lambda[XY], double lambdaBound) { @@ -610,8 +636,10 @@ static double gaussSeidel2Sor(double const M[XY][4], double omega, } lambda[i] = computeLambdaTopEnd(i, M, lambda); lambda[i] = std::clamp(lambda[i], min, max); - // Also solve the system from bottom to top, to help spread the updates - // better. + /* + * Also solve the system from bottom to top, to help spread the updates + * better. + */ lambda[i] = computeLambdaTopEnd(i, M, lambda); lambda[i] = std::clamp(lambda[i], min, max); for (i = XY - 2; i >= XY - X; i--) { @@ -637,7 +665,7 @@ static double gaussSeidel2Sor(double const M[XY][4], double omega, return maxDiff; } -// Normalise the values so that the smallest value is 1. +/* Normalise the values so that the smallest value is 1. */ static void normalise(double *ptr, size_t n) { double minval = ptr[0]; @@ -647,7 +675,7 @@ static void normalise(double *ptr, size_t n) ptr[i] /= minval; } -// Rescale the values so that the average value is 1. +/* Rescale the values so that the average value is 1. */ static void reaverage(Span data) { double sum = std::accumulate(data.begin(), data.end(), 0.0); @@ -670,15 +698,17 @@ static void runMatrixIterations(double const C[XY], double lambda[XY], << "Stop after " << i + 1 << " iterations"; break; } - // this happens very occasionally (so make a note), though - // doesn't seem to matter + /* + * this happens very occasionally (so make a note), though + * doesn't seem to matter + */ if (maxDiff > lastMaxDiff) LOG(RPiAlsc, Debug) << "Iteration " << i << ": maxDiff gone up " << lastMaxDiff << " to " << maxDiff; lastMaxDiff = maxDiff; } - // We're going to normalise the lambdas so the total average is 1. + /* We're going to normalise the lambdas so the total average is 1. */ reaverage({ lambda, XY }); } @@ -712,41 +742,49 @@ void addLuminanceToTables(double results[3][Y][X], double const lambdaR[XY], void Alsc::doAlsc() { double cr[XY], cb[XY], wr[XY][4], wb[XY][4], calTableR[XY], calTableB[XY], calTableTmp[XY]; - // Calculate our R/B ("Cr"/"Cb") colour statistics, and assess which are - // usable. + /* + * Calculate our R/B ("Cr"/"Cb") colour statistics, and assess which are + * usable. + */ calculateCrCb(statistics_, cr, cb, config_.minCount, config_.minG); - // Fetch the new calibrations (if any) for this CT. Resample them in - // case the camera mode is not full-frame. + /* + * Fetch the new calibrations (if any) for this CT. Resample them in + * case the camera mode is not full-frame. + */ getCalTable(ct_, config_.calibrationsCr, calTableTmp); resampleCalTable(calTableTmp, cameraMode_, calTableR); getCalTable(ct_, config_.calibrationsCb, calTableTmp); resampleCalTable(calTableTmp, cameraMode_, calTableB); - // You could print out the cal tables for this image here, if you're - // tuning the algorithm... - // Apply any calibration to the statistics, so the adaptive algorithm - // makes only the extra adjustments. + /* + * You could print out the cal tables for this image here, if you're + * tuning the algorithm... + * Apply any calibration to the statistics, so the adaptive algorithm + * makes only the extra adjustments. + */ applyCalTable(calTableR, cr); applyCalTable(calTableB, cb); - // Compute weights between zones. + /* Compute weights between zones. */ computeW(cr, config_.sigmaCr, wr); computeW(cb, config_.sigmaCb, wb); - // Run Gauss-Seidel iterations over the resulting matrix, for R and B. + /* Run Gauss-Seidel iterations over the resulting matrix, for R and B. */ runMatrixIterations(cr, lambdaR_, wr, config_.omega, config_.nIter, config_.threshold, config_.lambdaBound); runMatrixIterations(cb, lambdaB_, wb, config_.omega, config_.nIter, config_.threshold, config_.lambdaBound); - // Fold the calibrated gains into our final lambda values. (Note that on - // the next run, we re-start with the lambda values that don't have the - // calibration gains included.) + /* + * Fold the calibrated gains into our final lambda values. (Note that on + * the next run, we re-start with the lambda values that don't have the + * calibration gains included.) + */ compensateLambdasForCal(calTableR, lambdaR_, asyncLambdaR_); compensateLambdasForCal(calTableB, lambdaB_, asyncLambdaB_); - // Fold in the luminance table at the appropriate strength. + /* Fold in the luminance table at the appropriate strength. */ addLuminanceToTables(asyncResults_, asyncLambdaR_, 1.0, asyncLambdaB_, luminanceTable_, config_.luminanceStrength); } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return (Algorithm *)new Alsc(controller); diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.hpp b/src/ipa/raspberrypi/controller/rpi/alsc.hpp index 7a0949d1ccc5..3ffc175d78b6 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.hpp @@ -15,7 +15,7 @@ namespace RPiController { -// Algorithm to generate automagic LSC (Lens Shading Correction) tables. +/* Algorithm to generate automagic LSC (Lens Shading Correction) tables. */ struct AlscCalibration { double ct; @@ -23,11 +23,11 @@ struct AlscCalibration { }; struct AlscConfig { - // Only repeat the ALSC calculation every "this many" frames + /* Only repeat the ALSC calculation every "this many" frames */ uint16_t framePeriod; - // number of initial frames for which speed taken as 1.0 (maximum) + /* number of initial frames for which speed taken as 1.0 (maximum) */ uint16_t startupFrames; - // IIR filter speed applied to algorithm results + /* IIR filter speed applied to algorithm results */ double speed; double sigmaCr; double sigmaCb; @@ -39,9 +39,9 @@ struct AlscConfig { double luminanceStrength; std::vector calibrationsCr; std::vector calibrationsCb; - double defaultCt; // colour temperature if no metadata found - double threshold; // iteration termination threshold - double lambdaBound; // upper/lower bound for lambda from a value of 1 + double defaultCt; /* colour temperature if no metadata found */ + double threshold; /* iteration termination threshold */ + double lambdaBound; /* upper/lower bound for lambda from a value of 1 */ }; class Alsc : public Algorithm @@ -57,41 +57,45 @@ public: void process(StatisticsPtr &stats, Metadata *imageMetadata) override; private: - // configuration is read-only, and available to both threads + /* configuration is read-only, and available to both threads */ AlscConfig config_; bool firstTime_; CameraMode cameraMode_; double luminanceTable_[ALSC_CELLS_X * ALSC_CELLS_Y]; std::thread asyncThread_; - void asyncFunc(); // asynchronous thread function + void asyncFunc(); /* asynchronous thread function */ std::mutex mutex_; - // condvar for async thread to wait on + /* condvar for async thread to wait on */ std::condition_variable asyncSignal_; - // condvar for synchronous thread to wait on + /* condvar for synchronous thread to wait on */ std::condition_variable syncSignal_; - // for sync thread to check if async thread finished (requires mutex) + /* for sync thread to check if async thread finished (requires mutex) */ bool asyncFinished_; - // for async thread to check if it's been told to run (requires mutex) + /* for async thread to check if it's been told to run (requires mutex) */ bool asyncStart_; - // for async thread to check if it's been told to quit (requires mutex) + /* for async thread to check if it's been told to quit (requires mutex) */ bool asyncAbort_; - // The following are only for the synchronous thread to use: - // for sync thread to note its has asked async thread to run + /* + * The following are only for the synchronous thread to use: + * for sync thread to note its has asked async thread to run + */ bool asyncStarted_; - // counts up to framePeriod before restarting the async thread + /* counts up to framePeriod before restarting the async thread */ int framePhase_; - // counts up to startupFrames + /* counts up to startupFrames */ int frameCount_; - // counts up to startupFrames for Process function + /* counts up to startupFrames for Process function */ int frameCount2_; double syncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X]; double prevSyncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X]; void waitForAysncThread(); - // The following are for the asynchronous thread to use, though the main - // thread can set/reset them if the async thread is known to be idle: + /* + * The following are for the asynchronous thread to use, though the main + * thread can set/reset them if the async thread is known to be idle: + */ void restartAsync(StatisticsPtr &stats, Metadata *imageMetadata); - // copy out the results from the async thread so that it can be restarted + /* copy out the results from the async thread so that it can be restarted */ void fetchAsyncResults(); double ct_; bcm2835_isp_stats_region statistics_[ALSC_CELLS_Y * ALSC_CELLS_X]; @@ -103,4 +107,4 @@ private: double lambdaB_[ALSC_CELLS_X * ALSC_CELLS_Y]; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index a305237f31fb..4a7bc869cee4 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp @@ -21,8 +21,10 @@ LOG_DEFINE_CATEGORY(RPiAwb) #define AWB_STATS_SIZE_X DEFAULT_AWB_REGIONS_X #define AWB_STATS_SIZE_Y DEFAULT_AWB_REGIONS_Y -// todo - the locking in this algorithm needs some tidying up as has been done -// elsewhere (ALSC and AGC). +/* + * todo - the locking in this algorithm needs some tidying up as has been done + * elsewhere (ALSC and AGC). + */ void AwbMode::read(boost::property_tree::ptree const ¶ms) { @@ -107,11 +109,11 @@ void AwbConfig::read(boost::property_tree::ptree const ¶ms) bayes = false; } } - fast = params.get("fast", bayes); // default to fast for Bayesian, otherwise slow + fast = params.get("fast", bayes); /* default to fast for Bayesian, otherwise slow */ whitepointR = params.get("whitepoint_r", 0.0); whitepointB = params.get("whitepoint_b", 0.0); if (bayes == false) - sensitivityR = sensitivityB = 1.0; // nor do sensitivities make any sense + sensitivityR = sensitivityB = 1.0; /* nor do sensitivities make any sense */ } Awb::Awb(Controller *controller) @@ -147,16 +149,18 @@ void Awb::read(boost::property_tree::ptree const ¶ms) void Awb::initialise() { frameCount_ = framePhase_ = 0; - // Put something sane into the status that we are filtering towards, - // just in case the first few frames don't have anything meaningful in - // them. + /* + * Put something sane into the status that we are filtering towards, + * just in case the first few frames don't have anything meaningful in + * them. + */ if (!config_.ctR.empty() && !config_.ctB.empty()) { syncResults_.temperatureK = config_.ctR.domain().clip(4000); syncResults_.gainR = 1.0 / config_.ctR.eval(syncResults_.temperatureK); syncResults_.gainG = 1.0; syncResults_.gainB = 1.0 / config_.ctB.eval(syncResults_.temperatureK); } else { - // random values just to stop the world blowing up + /* random values just to stop the world blowing up */ syncResults_.temperatureK = 4500; syncResults_.gainR = syncResults_.gainG = syncResults_.gainB = 1.0; } @@ -171,7 +175,7 @@ bool Awb::isPaused() const void Awb::pause() { - // "Pause" by fixing everything to the most recent values. + /* "Pause" by fixing everything to the most recent values. */ manualR_ = syncResults_.gainR = prevSyncResults_.gainR; manualB_ = syncResults_.gainB = prevSyncResults_.gainB; syncResults_.gainG = prevSyncResults_.gainG; @@ -186,8 +190,10 @@ void Awb::resume() unsigned int Awb::getConvergenceFrames() const { - // If not in auto mode, there is no convergence - // to happen, so no need to drop any frames - return zero. + /* + * If not in auto mode, there is no convergence + * to happen, so no need to drop any frames - return zero. + */ if (!isAutoEnabled()) return 0; else @@ -201,11 +207,13 @@ void Awb::setMode(std::string const &modeName) void Awb::setManualGains(double manualR, double manualB) { - // If any of these are 0.0, we swich back to auto. + /* If any of these are 0.0, we swich back to auto. */ manualR_ = manualR; manualB_ = manualB; - // If not in auto mode, set these values into the syncResults which - // means that Prepare() will adopt them immediately. + /* + * If not in auto mode, set these values into the syncResults which + * means that Prepare() will adopt them immediately. + */ if (!isAutoEnabled()) { syncResults_.gainR = prevSyncResults_.gainR = manualR_; syncResults_.gainG = prevSyncResults_.gainG = 1.0; @@ -216,8 +224,10 @@ void Awb::setManualGains(double manualR, double manualB) void Awb::switchMode([[maybe_unused]] CameraMode const &cameraMode, Metadata *metadata) { - // On the first mode switch we'll have no meaningful colour - // temperature, so try to dead reckon one if in manual mode. + /* + * On the first mode switch we'll have no meaningful colour + * temperature, so try to dead reckon one if in manual mode. + */ if (!isAutoEnabled() && firstSwitchMode_ && config_.bayes) { Pwl ctRInverse = config_.ctR.inverse(); Pwl ctBInverse = config_.ctB.inverse(); @@ -226,7 +236,7 @@ void Awb::switchMode([[maybe_unused]] CameraMode const &cameraMode, prevSyncResults_.temperatureK = (ctR + ctB) / 2; syncResults_.temperatureK = prevSyncResults_.temperatureK; } - // Let other algorithms know the current white balance values. + /* Let other algorithms know the current white balance values. */ metadata->set("awb.status", prevSyncResults_); firstSwitchMode_ = false; } @@ -241,8 +251,10 @@ void Awb::fetchAsyncResults() LOG(RPiAwb, Debug) << "Fetch AWB results"; asyncFinished_ = false; asyncStarted_ = false; - // It's possible manual gains could be set even while the async - // thread was running, so only copy the results if still in auto mode. + /* + * It's possible manual gains could be set even while the async + * thread was running, so only copy the results if still in auto mode. + */ if (isAutoEnabled()) syncResults_ = asyncResults_; } @@ -250,9 +262,9 @@ void Awb::fetchAsyncResults() void Awb::restartAsync(StatisticsPtr &stats, double lux) { LOG(RPiAwb, Debug) << "Starting AWB calculation"; - // this makes a new reference which belongs to the asynchronous thread + /* this makes a new reference which belongs to the asynchronous thread */ statistics_ = stats; - // store the mode as it could technically change + /* store the mode as it could technically change */ auto m = config_.modes.find(modeName_); mode_ = m != config_.modes.end() ? &m->second @@ -284,7 +296,7 @@ void Awb::prepare(Metadata *imageMetadata) if (asyncStarted_ && asyncFinished_) fetchAsyncResults(); } - // Finally apply IIR filter to results and put into metadata. + /* Finally apply IIR filter to results and put into metadata. */ memcpy(prevSyncResults_.mode, syncResults_.mode, sizeof(prevSyncResults_.mode)); prevSyncResults_.temperatureK = speed * syncResults_.temperatureK + @@ -304,17 +316,17 @@ void Awb::prepare(Metadata *imageMetadata) void Awb::process(StatisticsPtr &stats, Metadata *imageMetadata) { - // Count frames since we last poked the async thread. + /* Count frames since we last poked the async thread. */ if (framePhase_ < (int)config_.framePeriod) framePhase_++; LOG(RPiAwb, Debug) << "frame_phase " << framePhase_; - // We do not restart the async thread if we're not in auto mode. + /* We do not restart the async thread if we're not in auto mode. */ if (isAutoEnabled() && (framePhase_ >= (int)config_.framePeriod || frameCount_ < (int)config_.startupFrames)) { - // Update any settings and any image metadata that we need. + /* Update any settings and any image metadata that we need. */ struct LuxStatus luxStatus = {}; - luxStatus.lux = 400; // in case no metadata + luxStatus.lux = 400; /* in case no metadata */ if (imageMetadata->get("lux.status", luxStatus) != 0) LOG(RPiAwb, Debug) << "No lux metadata found"; LOG(RPiAwb, Debug) << "Awb lux value is " << luxStatus.lux; @@ -366,15 +378,21 @@ static void generateStats(std::vector &zones, void Awb::prepareStats() { zones_.clear(); - // LSC has already been applied to the stats in this pipeline, so stop - // any LSC compensation. We also ignore config_.fast in this version. + /* + * LSC has already been applied to the stats in this pipeline, so stop + * any LSC compensation. We also ignore config_.fast in this version. + */ generateStats(zones_, statistics_->awb_stats, config_.minPixels, config_.minG); - // we're done with these; we may as well relinquish our hold on the - // pointer. + /* + * we're done with these; we may as well relinquish our hold on the + * pointer. + */ statistics_.reset(); - // apply sensitivities, so values appear to come from our "canonical" - // sensor. + /* + * apply sensitivities, so values appear to come from our "canonical" + * sensor. + */ for (auto &zone : zones_) { zone.R *= config_.sensitivityR; zone.B *= config_.sensitivityB; @@ -383,14 +401,16 @@ void Awb::prepareStats() double Awb::computeDelta2Sum(double gainR, double gainB) { - // Compute the sum of the squared colour error (non-greyness) as it - // appears in the log likelihood equation. + /* + * Compute the sum of the squared colour error (non-greyness) as it + * appears in the log likelihood equation. + */ double delta2Sum = 0; for (auto &z : zones_) { double deltaR = gainR * z.R - 1 - config_.whitepointR; double deltaB = gainB * z.B - 1 - config_.whitepointB; double delta2 = deltaR * deltaR + deltaB * deltaB; - //LOG(RPiAwb, Debug) << "delta_r " << delta_r << " delta_b " << delta_b << " delta2 " << delta2; + /*LOG(RPiAwb, Debug) << "delta_r " << delta_r << " delta_b " << delta_b << " delta2 " << delta2; */ delta2 = std::min(delta2, config_.deltaLimit); delta2Sum += delta2; } @@ -399,15 +419,17 @@ double Awb::computeDelta2Sum(double gainR, double gainB) Pwl Awb::interpolatePrior() { - // Interpolate the prior log likelihood function for our current lux - // value. + /* + * Interpolate the prior log likelihood function for our current lux + * value. + */ if (lux_ <= config_.priors.front().lux) return config_.priors.front().prior; else if (lux_ >= config_.priors.back().lux) return config_.priors.back().prior; else { int idx = 0; - // find which two we lie between + /* find which two we lie between */ while (config_.priors[idx + 1].lux < lux_) idx++; double lux0 = config_.priors[idx].lux, @@ -424,8 +446,10 @@ Pwl Awb::interpolatePrior() static double interpolateQuadatric(Pwl::Point const &a, Pwl::Point const &b, Pwl::Point const &c) { - // Given 3 points on a curve, find the extremum of the function in that - // interval by fitting a quadratic. + /* + * Given 3 points on a curve, find the extremum of the function in that + * interval by fitting a quadratic. + */ const double eps = 1e-3; Pwl::Point ca = c - a, ba = b - a; double denominator = 2 * (ba.y * ca.x - ca.y * ba.x); @@ -434,17 +458,17 @@ static double interpolateQuadatric(Pwl::Point const &a, Pwl::Point const &b, double result = numerator / denominator + a.x; return std::max(a.x, std::min(c.x, result)); } - // has degenerated to straight line segment + /* has degenerated to straight line segment */ return a.y < c.y - eps ? a.x : (c.y < a.y - eps ? c.x : b.x); } double Awb::coarseSearch(Pwl const &prior) { - points_.clear(); // assume doesn't deallocate memory + points_.clear(); /* assume doesn't deallocate memory */ size_t bestPoint = 0; double t = mode_->ctLo; int spanR = 0, spanB = 0; - // Step down the CT curve evaluating log likelihood. + /* Step down the CT curve evaluating log likelihood. */ while (true) { double r = config_.ctR.eval(t, &spanR); double b = config_.ctB.eval(t, &spanB); @@ -462,13 +486,15 @@ double Awb::coarseSearch(Pwl const &prior) bestPoint = points_.size() - 1; if (t == mode_->ctHi) break; - // for even steps along the r/b curve scale them by the current t + /* for even steps along the r/b curve scale them by the current t */ t = std::min(t + t / 10 * config_.coarseStep, mode_->ctHi); } t = points_[bestPoint].x; LOG(RPiAwb, Debug) << "Coarse search found CT " << t; - // We have the best point of the search, but refine it with a quadratic - // interpolation around its neighbours. + /* + * We have the best point of the search, but refine it with a quadratic + * interpolation around its neighbours. + */ if (points_.size() > 2) { unsigned long bp = std::min(bestPoint, points_.size() - 2); bestPoint = std::max(1UL, bp); @@ -496,17 +522,21 @@ void Awb::fineSearch(double &t, double &r, double &b, Pwl const &prior) Pwl::Point transverse(bDiff, -rDiff); if (transverse.len2() < 1e-6) return; - // unit vector orthogonal to the b vs. r function (pointing outwards - // with r and b increasing) + /* + * unit vector orthogonal to the b vs. r function (pointing outwards + * with r and b increasing) + */ transverse = transverse / transverse.len(); double bestLogLikelihood = 0, bestT = 0, bestR = 0, bestB = 0; double transverseRange = config_.transverseNeg + config_.transversePos; const int maxNumDeltas = 12; - // a transverse step approximately every 0.01 r/b units + /* a transverse step approximately every 0.01 r/b units */ int numDeltas = floor(transverseRange * 100 + 0.5) + 1; numDeltas = numDeltas < 3 ? 3 : (numDeltas > maxNumDeltas ? maxNumDeltas : numDeltas); - // Step down CT curve. March a bit further if the transverse range is - // large. + /* + * Step down CT curve. March a bit further if the transverse range is + * large. + */ nsteps += numDeltas; for (int i = -nsteps; i <= nsteps; i++) { double tTest = t + i * step; @@ -514,10 +544,10 @@ void Awb::fineSearch(double &t, double &r, double &b, Pwl const &prior) prior.eval(prior.domain().clip(tTest)); double rCurve = config_.ctR.eval(tTest, &spanR); double bCurve = config_.ctB.eval(tTest, &spanB); - // x will be distance off the curve, y the log likelihood there + /* x will be distance off the curve, y the log likelihood there */ Pwl::Point points[maxNumDeltas]; int bestPoint = 0; - // Take some measurements transversely *off* the CT curve. + /* Take some measurements transversely *off* the CT curve. */ for (int j = 0; j < numDeltas; j++) { points[j].x = -config_.transverseNeg + (transverseRange * j) / (numDeltas - 1); @@ -533,8 +563,10 @@ void Awb::fineSearch(double &t, double &r, double &b, Pwl const &prior) if (points[j].y < points[bestPoint].y) bestPoint = j; } - // We have NUM_DELTAS points transversely across the CT curve, - // now let's do a quadratic interpolation for the best result. + /* + * We have NUM_DELTAS points transversely across the CT curve, + * now let's do a quadratic interpolation for the best result. + */ bestPoint = std::max(1, std::min(bestPoint, numDeltas - 2)); Pwl::Point rbTest = Pwl::Point(rCurve, bCurve) + transverse * interpolateQuadatric(points[bestPoint - 1], @@ -560,12 +592,16 @@ void Awb::fineSearch(double &t, double &r, double &b, Pwl const &prior) void Awb::awbBayes() { - // May as well divide out G to save computeDelta2Sum from doing it over - // and over. + /* + * May as well divide out G to save computeDelta2Sum from doing it over + * and over. + */ for (auto &z : zones_) z.R = z.R / (z.G + 1), z.B = z.B / (z.G + 1); - // Get the current prior, and scale according to how many zones are - // valid... not entirely sure about this. + /* + * Get the current prior, and scale according to how many zones are + * valid... not entirely sure about this. + */ Pwl prior = interpolatePrior(); prior *= zones_.size() / (double)(AWB_STATS_SIZE_X * AWB_STATS_SIZE_Y); prior.map([](double x, double y) { @@ -577,19 +613,23 @@ void Awb::awbBayes() LOG(RPiAwb, Debug) << "After coarse search: r " << r << " b " << b << " (gains r " << 1 / r << " b " << 1 / b << ")"; - // Not entirely sure how to handle the fine search yet. Mostly the - // estimated CT is already good enough, but the fine search allows us to - // wander transverely off the CT curve. Under some illuminants, where - // there may be more or less green light, this may prove beneficial, - // though I probably need more real datasets before deciding exactly how - // this should be controlled and tuned. + /* + * Not entirely sure how to handle the fine search yet. Mostly the + * estimated CT is already good enough, but the fine search allows us to + * wander transverely off the CT curve. Under some illuminants, where + * there may be more or less green light, this may prove beneficial, + * though I probably need more real datasets before deciding exactly how + * this should be controlled and tuned. + */ fineSearch(t, r, b, prior); LOG(RPiAwb, Debug) << "After fine search: r " << r << " b " << b << " (gains r " << 1 / r << " b " << 1 / b << ")"; - // Write results out for the main thread to pick up. Remember to adjust - // the gains from the ones that the "canonical sensor" would require to - // the ones needed by *this* sensor. + /* + * Write results out for the main thread to pick up. Remember to adjust + * the gains from the ones that the "canonical sensor" would require to + * the ones needed by *this* sensor. + */ asyncResults_.temperatureK = t; asyncResults_.gainR = 1.0 / r * config_.sensitivityR; asyncResults_.gainG = 1.0; @@ -599,10 +639,12 @@ void Awb::awbBayes() void Awb::awbGrey() { LOG(RPiAwb, Debug) << "Grey world AWB"; - // Make a separate list of the derivatives for each of red and blue, so - // that we can sort them to exclude the extreme gains. We could - // consider some variations, such as normalising all the zones first, or - // doing an L2 average etc. + /* + * Make a separate list of the derivatives for each of red and blue, so + * that we can sort them to exclude the extreme gains. We could + * consider some variations, such as normalising all the zones first, or + * doing an L2 average etc. + */ std::vector &derivsR(zones_); std::vector derivsB(derivsR); std::sort(derivsR.begin(), derivsR.end(), @@ -613,7 +655,7 @@ void Awb::awbGrey() [](RGB const &a, RGB const &b) { return a.G * b.B < b.G * a.B; }); - // Average the middle half of the values. + /* Average the middle half of the values. */ int discard = derivsR.size() / 4; RGB sumR(0, 0, 0), sumB(0, 0, 0); for (auto ri = derivsR.begin() + discard, @@ -622,7 +664,7 @@ void Awb::awbGrey() sumR += *ri, sumB += *bi; double gainR = sumR.G / (sumR.R + 1), gainB = sumB.G / (sumB.B + 1); - asyncResults_.temperatureK = 4500; // don't know what it is + asyncResults_.temperatureK = 4500; /* don't know what it is */ asyncResults_.gainR = gainR; asyncResults_.gainG = 1.0; asyncResults_.gainB = gainB; @@ -645,7 +687,7 @@ void Awb::doAwb() } } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return (Algorithm *)new Awb(controller); diff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp b/src/ipa/raspberrypi/controller/rpi/awb.hpp index 91251d6be2da..597f3182da44 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.hpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp @@ -16,63 +16,73 @@ namespace RPiController { -// Control algorithm to perform AWB calculations. +/* Control algorithm to perform AWB calculations. */ struct AwbMode { void read(boost::property_tree::ptree const ¶ms); - double ctLo; // low CT value for search - double ctHi; // high CT value for search + double ctLo; /* low CT value for search */ + double ctHi; /* high CT value for search */ }; struct AwbPrior { void read(boost::property_tree::ptree const ¶ms); - double lux; // lux level - Pwl prior; // maps CT to prior log likelihood for this lux level + double lux; /* lux level */ + Pwl prior; /* maps CT to prior log likelihood for this lux level */ }; struct AwbConfig { AwbConfig() : defaultMode(nullptr) {} void read(boost::property_tree::ptree const ¶ms); - // Only repeat the AWB calculation every "this many" frames + /* Only repeat the AWB calculation every "this many" frames */ uint16_t framePeriod; - // number of initial frames for which speed taken as 1.0 (maximum) + /* number of initial frames for which speed taken as 1.0 (maximum) */ uint16_t startupFrames; - unsigned int convergenceFrames; // approx number of frames to converge - double speed; // IIR filter speed applied to algorithm results - bool fast; // "fast" mode uses a 16x16 rather than 32x32 grid - Pwl ctR; // function maps CT to r (= R/G) - Pwl ctB; // function maps CT to b (= B/G) - // table of illuminant priors at different lux levels + unsigned int convergenceFrames; /* approx number of frames to converge */ + double speed; /* IIR filter speed applied to algorithm results */ + bool fast; /* "fast" mode uses a 16x16 rather than 32x32 grid */ + Pwl ctR; /* function maps CT to r (= R/G) */ + Pwl ctB; /* + Pwl ctB; * function maps CT to b (= B/G) + * table of illuminant priors at different lux levels + */ std::vector priors; - // AWB "modes" (determines the search range) + /* AWB "modes" (determines the search range) */ std::map modes; - AwbMode *defaultMode; // mode used if no mode selected - // minimum proportion of pixels counted within AWB region for it to be - // "useful" + AwbMode *defaultMode; /* mode used if no mode selected */ + /* + * minimum proportion of pixels counted within AWB region for it to be + * "useful" + */ double minPixels; - // minimum G value of those pixels, to be regarded a "useful" + /* minimum G value of those pixels, to be regarded a "useful" */ uint16_t minG; - // number of AWB regions that must be "useful" in order to do the AWB - // calculation + /* + * number of AWB regions that must be "useful" in order to do the AWB + * calculation + */ uint32_t minRegions; - // clamp on colour error term (so as not to penalise non-grey excessively) + /* clamp on colour error term (so as not to penalise non-grey excessively) */ double deltaLimit; - // step size control in coarse search + /* step size control in coarse search */ double coarseStep; - // how far to wander off CT curve towards "more purple" + /* how far to wander off CT curve towards "more purple" */ double transversePos; - // how far to wander off CT curve towards "more green" + /* how far to wander off CT curve towards "more green" */ double transverseNeg; - // red sensitivity ratio (set to canonical sensor's R/G divided by this - // sensor's R/G) + /* + * red sensitivity ratio (set to canonical sensor's R/G divided by this + * sensor's R/G) + */ double sensitivityR; - // blue sensitivity ratio (set to canonical sensor's B/G divided by this - // sensor's B/G) + /* + * blue sensitivity ratio (set to canonical sensor's B/G divided by this + * sensor's B/G) + */ double sensitivityB; - // The whitepoint (which we normally "aim" for) can be moved. + /* The whitepoint (which we normally "aim" for) can be moved. */ double whitepointR; double whitepointB; - bool bayes; // use Bayesian algorithm + bool bayes; /* use Bayesian algorithm */ }; class Awb : public AwbAlgorithm @@ -83,7 +93,7 @@ public: char const *name() const override; void initialise() override; void read(boost::property_tree::ptree const ¶ms) override; - // AWB handles "pausing" for itself. + /* AWB handles "pausing" for itself. */ bool isPaused() const override; void pause() override; void resume() override; @@ -108,35 +118,39 @@ public: private: bool isAutoEnabled() const; - // configuration is read-only, and available to both threads + /* configuration is read-only, and available to both threads */ AwbConfig config_; std::thread asyncThread_; - void asyncFunc(); // asynchronous thread function + void asyncFunc(); /* asynchronous thread function */ std::mutex mutex_; - // condvar for async thread to wait on + /* condvar for async thread to wait on */ std::condition_variable asyncSignal_; - // condvar for synchronous thread to wait on + /* condvar for synchronous thread to wait on */ std::condition_variable syncSignal_; - // for sync thread to check if async thread finished (requires mutex) + /* for sync thread to check if async thread finished (requires mutex) */ bool asyncFinished_; - // for async thread to check if it's been told to run (requires mutex) + /* for async thread to check if it's been told to run (requires mutex) */ bool asyncStart_; - // for async thread to check if it's been told to quit (requires mutex) + /* for async thread to check if it's been told to quit (requires mutex) */ bool asyncAbort_; - // The following are only for the synchronous thread to use: - // for sync thread to note its has asked async thread to run + /* + * The following are only for the synchronous thread to use: + * for sync thread to note its has asked async thread to run + */ bool asyncStarted_; - // counts up to framePeriod before restarting the async thread + /* counts up to framePeriod before restarting the async thread */ int framePhase_; - int frameCount_; // counts up to startup_frames + int frameCount_; /* counts up to startup_frames */ AwbStatus syncResults_; AwbStatus prevSyncResults_; std::string modeName_; - // The following are for the asynchronous thread to use, though the main - // thread can set/reset them if the async thread is known to be idle: + /* + * The following are for the asynchronous thread to use, though the main + * thread can set/reset them if the async thread is known to be idle: + */ void restartAsync(StatisticsPtr &stats, double lux); - // copy out the results from the async thread so that it can be restarted + /* copy out the results from the async thread so that it can be restarted */ void fetchAsyncResults(); StatisticsPtr statistics_; AwbMode *mode_; @@ -152,11 +166,11 @@ private: void fineSearch(double &t, double &r, double &b, Pwl const &prior); std::vector zones_; std::vector points_; - // manual r setting + /* manual r setting */ double manualR_; - // manual b setting + /* manual b setting */ double manualB_; - bool firstSwitchMode_; // is this the first call to SwitchMode? + bool firstSwitchMode_; /* is this the first call to SwitchMode? */ }; static inline Awb::RGB operator+(Awb::RGB const &a, Awb::RGB const &b) @@ -176,4 +190,4 @@ static inline Awb::RGB operator*(Awb::RGB const &rgb, double d) return d * rgb; } -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.cpp b/src/ipa/raspberrypi/controller/rpi/black_level.cpp index 101b5ea92cf5..4432faa6485a 100644 --- a/src/ipa/raspberrypi/controller/rpi/black_level.cpp +++ b/src/ipa/raspberrypi/controller/rpi/black_level.cpp @@ -34,7 +34,7 @@ char const *BlackLevel::name() const void BlackLevel::read(boost::property_tree::ptree const ¶ms) { uint16_t blackLevel = params.get( - "black_level", 4096); // 64 in 10 bits scaled to 16 bits + "black_level", 4096); /* 64 in 10 bits scaled to 16 bits */ blackLevelR_ = params.get("blackLevelR", blackLevel); blackLevelG_ = params.get("blackLevelG", blackLevel); blackLevelB_ = params.get("blackLevelB", blackLevel); @@ -46,8 +46,10 @@ void BlackLevel::read(boost::property_tree::ptree const ¶ms) void BlackLevel::prepare(Metadata *imageMetadata) { - // Possibly we should think about doing this in a switchMode or - // something? + /* + * Possibly we should think about doing this in a switchMode or + * something? + */ struct BlackLevelStatus status; status.blackLevelR = blackLevelR_; status.blackLevelG = blackLevelG_; @@ -55,7 +57,7 @@ void BlackLevel::prepare(Metadata *imageMetadata) imageMetadata->set("black_level.status", status); } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return new BlackLevel(controller); diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.hpp b/src/ipa/raspberrypi/controller/rpi/black_level.hpp index 0d74f6a4c49b..f01c55151288 100644 --- a/src/ipa/raspberrypi/controller/rpi/black_level.hpp +++ b/src/ipa/raspberrypi/controller/rpi/black_level.hpp @@ -9,7 +9,7 @@ #include "../algorithm.hpp" #include "../black_level_status.h" -// This is our implementation of the "black level algorithm". +/* This is our implementation of the "black level algorithm". */ namespace RPiController { @@ -27,4 +27,4 @@ private: double blackLevelB_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.cpp b/src/ipa/raspberrypi/controller/rpi/ccm.cpp index 24d8e5bd1fd8..9ad63b6e20d9 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.cpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.cpp @@ -19,11 +19,13 @@ using namespace libcamera; LOG_DEFINE_CATEGORY(RPiCcm) -// This algorithm selects a CCM (Colour Correction Matrix) according to the -// colour temperature estimated by AWB (interpolating between known matricies as -// necessary). Additionally the amount of colour saturation can be controlled -// both according to the current estimated lux level and according to a -// saturation setting that is exposed to applications. +/* + * This algorithm selects a CCM (Colour Correction Matrix) according to the + * colour temperature estimated by AWB (interpolating between known matricies as + * necessary). Additionally the amount of colour saturation can be controlled + * both according to the current estimated lux level and according to a + * saturation setting that is exposed to applications. + */ #define NAME "rpi.ccm" @@ -125,11 +127,11 @@ void Ccm::prepare(Metadata *imageMetadata) { bool awbOk = false, luxOk = false; struct AwbStatus awb = {}; - awb.temperatureK = 4000; // in case no metadata + awb.temperatureK = 4000; /* in case no metadata */ struct LuxStatus lux = {}; - lux.lux = 400; // in case no metadata + lux.lux = 400; /* in case no metadata */ { - // grab mutex just once to get everything + /* grab mutex just once to get everything */ std::lock_guard lock(*imageMetadata); awbOk = getLocked(imageMetadata, "awb.status", awb); luxOk = getLocked(imageMetadata, "lux.status", lux); @@ -162,7 +164,7 @@ void Ccm::prepare(Metadata *imageMetadata) imageMetadata->set("ccm.status", ccmStatus); } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return (Algorithm *)new Ccm(controller); diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.hpp b/src/ipa/raspberrypi/controller/rpi/ccm.hpp index 4c4807b8a942..7622044ce49c 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.hpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.hpp @@ -13,7 +13,7 @@ namespace RPiController { -// Algorithm to calculate colour matrix. Should be placed after AWB. +/* Algorithm to calculate colour matrix. Should be placed after AWB. */ struct Matrix { Matrix(double m0, double m1, double m2, double m3, double m4, double m5, @@ -72,4 +72,4 @@ private: double saturation_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.cpp b/src/ipa/raspberrypi/controller/rpi/contrast.cpp index 169837576678..f11c834a0192 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.cpp +++ b/src/ipa/raspberrypi/controller/rpi/contrast.cpp @@ -18,11 +18,13 @@ using namespace libcamera; LOG_DEFINE_CATEGORY(RPiContrast) -// This is a very simple control algorithm which simply retrieves the results of -// AGC and AWB via their "status" metadata, and applies digital gain to the -// colour channels in accordance with those instructions. We take care never to -// apply less than unity gains, as that would cause fully saturated pixels to go -// off-white. +/* + * This is a very simple control algorithm which simply retrieves the results of + * AGC and AWB via their "status" metadata, and applies digital gain to the + * colour channels in accordance with those instructions. We take care never to + * apply less than unity gains, as that would cause fully saturated pixels to go + * off-white. + */ #define NAME "rpi.contrast" @@ -38,15 +40,15 @@ char const *Contrast::name() const void Contrast::read(boost::property_tree::ptree const ¶ms) { - // enable adaptive enhancement by default + /* enable adaptive enhancement by default */ config_.ceEnable = params.get("ce_enable", 1); - // the point near the bottom of the histogram to move + /* the point near the bottom of the histogram to move */ config_.loHistogram = params.get("lo_histogram", 0.01); - // where in the range to try and move it to + /* where in the range to try and move it to */ config_.loLevel = params.get("lo_level", 0.015); - // but don't move by more than this + /* but don't move by more than this */ config_.loMax = params.get("lo_max", 500); - // equivalent values for the top of the histogram... + /* equivalent values for the top of the histogram... */ config_.hiHistogram = params.get("hi_histogram", 0.95); config_.hiLevel = params.get("hi_level", 0.95); config_.hiMax = params.get("hi_max", 2000); @@ -81,8 +83,10 @@ static void fillInStatus(ContrastStatus &status, double brightness, void Contrast::initialise() { - // Fill in some default values as Prepare will run before Process gets - // called. + /* + * Fill in some default values as Prepare will run before Process gets + * called. + */ fillInStatus(status_, brightness_, contrast_, config_.gammaCurve); } @@ -97,8 +101,10 @@ Pwl computeStretchCurve(Histogram const &histogram, { Pwl enhance; enhance.append(0, 0); - // If the start of the histogram is rather empty, try to pull it down a - // bit. + /* + * If the start of the histogram is rather empty, try to pull it down a + * bit. + */ double histLo = histogram.quantile(config.loHistogram) * (65536 / NUM_HISTOGRAM_BINS); double levelLo = config.loLevel * 65536; @@ -109,13 +115,17 @@ Pwl computeStretchCurve(Histogram const &histogram, LOG(RPiContrast, Debug) << "Final values " << histLo << " -> " << levelLo; enhance.append(histLo, levelLo); - // Keep the mid-point (median) in the same place, though, to limit the - // apparent amount of global brightness shift. + /* + * Keep the mid-point (median) in the same place, though, to limit the + * apparent amount of global brightness shift. + */ double mid = histogram.quantile(0.5) * (65536 / NUM_HISTOGRAM_BINS); enhance.append(mid, mid); - // If the top to the histogram is empty, try to pull the pixel values - // there up. + /* + * If the top to the histogram is empty, try to pull the pixel values + * there up. + */ double histHi = histogram.quantile(config.hiHistogram) * (65536 / NUM_HISTOGRAM_BINS); double levelHi = config.hiLevel * 65536; @@ -149,22 +159,30 @@ void Contrast::process(StatisticsPtr &stats, [[maybe_unused]] Metadata *imageMetadata) { Histogram histogram(stats->hist[0].g_hist, NUM_HISTOGRAM_BINS); - // We look at the histogram and adjust the gamma curve in the following - // ways: 1. Adjust the gamma curve so as to pull the start of the - // histogram down, and possibly push the end up. + /* + * We look at the histogram and adjust the gamma curve in the following + * ways: 1. Adjust the gamma curve so as to pull the start of the + * histogram down, and possibly push the end up. + */ Pwl gammaCurve = config_.gammaCurve; if (config_.ceEnable) { if (config_.loMax != 0 || config_.hiMax != 0) gammaCurve = computeStretchCurve(histogram, config_).compose(gammaCurve); - // We could apply other adjustments (e.g. partial equalisation) - // based on the histogram...? + /* + * We could apply other adjustments (e.g. partial equalisation) + * based on the histogram...? + */ } - // 2. Finally apply any manually selected brightness/contrast - // adjustment. + /* + * 2. Finally apply any manually selected brightness/contrast + * adjustment. + */ if (brightness_ != 0 || contrast_ != 1.0) gammaCurve = applyManualContrast(gammaCurve, brightness_, contrast_); - // And fill in the status for output. Use more points towards the bottom - // of the curve. + /* + * And fill in the status for output. Use more points towards the bottom + * of the curve. + */ ContrastStatus status; fillInStatus(status, brightness_, contrast_, gammaCurve); { @@ -173,7 +191,7 @@ void Contrast::process(StatisticsPtr &stats, } } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return (Algorithm *)new Contrast(controller); diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.hpp b/src/ipa/raspberrypi/controller/rpi/contrast.hpp index 5a6d530f63fd..4793dedc10ff 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.hpp +++ b/src/ipa/raspberrypi/controller/rpi/contrast.hpp @@ -13,8 +13,10 @@ namespace RPiController { -// Back End algorithm to appaly correct digital gain. Should be placed after -// Back End AWB. +/* + * Back End algorithm to appaly correct digital gain. Should be placed after + * Back End AWB. + */ struct ContrastConfig { bool ceEnable; @@ -47,4 +49,4 @@ private: std::mutex mutex_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.cpp b/src/ipa/raspberrypi/controller/rpi/dpc.cpp index 42154cf300b8..68ba5e3e37bb 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/dpc.cpp @@ -14,8 +14,10 @@ using namespace libcamera; LOG_DEFINE_CATEGORY(RPiDpc) -// We use the lux status so that we can apply stronger settings in darkness (if -// necessary). +/* + * We use the lux status so that we can apply stronger settings in darkness (if + * necessary). + */ #define NAME "rpi.dpc" @@ -39,13 +41,13 @@ void Dpc::read(boost::property_tree::ptree const ¶ms) void Dpc::prepare(Metadata *imageMetadata) { DpcStatus dpcStatus = {}; - // Should we vary this with lux level or analogue gain? TBD. + /* Should we vary this with lux level or analogue gain? TBD. */ dpcStatus.strength = config_.strength; LOG(RPiDpc, Debug) << "strength " << dpcStatus.strength; imageMetadata->set("dpc.status", dpcStatus); } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return (Algorithm *)new Dpc(controller); diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.hpp b/src/ipa/raspberrypi/controller/rpi/dpc.hpp index 039310cc8d05..048fa2b8405e 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/dpc.hpp @@ -11,7 +11,7 @@ namespace RPiController { -// Back End algorithm to apply appropriate GEQ settings. +/* Back End algorithm to apply appropriate GEQ settings. */ struct DpcConfig { int strength; @@ -29,4 +29,4 @@ private: DpcConfig config_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/geq.cpp b/src/ipa/raspberrypi/controller/rpi/geq.cpp index 0da5efdf3d3d..14f226cf989c 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.cpp +++ b/src/ipa/raspberrypi/controller/rpi/geq.cpp @@ -18,8 +18,10 @@ using namespace libcamera; LOG_DEFINE_CATEGORY(RPiGeq) -// We use the lux status so that we can apply stronger settings in darkness (if -// necessary). +/* + * We use the lux status so that we can apply stronger settings in darkness (if + * necessary). + */ #define NAME "rpi.geq" @@ -50,7 +52,7 @@ void Geq::prepare(Metadata *imageMetadata) if (imageMetadata->get("lux.status", luxStatus)) LOG(RPiGeq, Warning) << "no lux data found"; DeviceStatus deviceStatus; - deviceStatus.analogueGain = 1.0; // in case not found + deviceStatus.analogueGain = 1.0; /* in case not found */ if (imageMetadata->get("device.status", deviceStatus)) LOG(RPiGeq, Warning) << "no device metadata - use analogue gain of 1x"; @@ -71,7 +73,7 @@ void Geq::prepare(Metadata *imageMetadata) imageMetadata->set("geq.status", geqStatus); } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return (Algorithm *)new Geq(controller); diff --git a/src/ipa/raspberrypi/controller/rpi/geq.hpp b/src/ipa/raspberrypi/controller/rpi/geq.hpp index bdbc55b2e2d9..5ea424fc768d 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.hpp +++ b/src/ipa/raspberrypi/controller/rpi/geq.hpp @@ -11,12 +11,12 @@ namespace RPiController { -// Back End algorithm to apply appropriate GEQ settings. +/* Back End algorithm to apply appropriate GEQ settings. */ struct GeqConfig { uint16_t offset; double slope; - Pwl strength; // lux to strength factor + Pwl strength; /* lux to strength factor */ }; class Geq : public Algorithm @@ -31,4 +31,4 @@ private: GeqConfig config_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/lux.cpp b/src/ipa/raspberrypi/controller/rpi/lux.cpp index 739a3d533874..a76ec7296def 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -25,8 +25,10 @@ LOG_DEFINE_CATEGORY(RPiLux) Lux::Lux(Controller *controller) : Algorithm(controller) { - // Put in some defaults as there will be no meaningful values until - // Process has run. + /* + * Put in some defaults as there will be no meaningful values until + * Process has run. + */ status_.aperture = 1.0; status_.lux = 400; } @@ -71,7 +73,7 @@ void Lux::process(StatisticsPtr &stats, Metadata *imageMetadata) sizeof(stats->hist[0].g_hist[0]); for (int i = 0; i < numBins; i++) sum += bin[i] * (uint64_t)i, num += bin[i]; - // add .5 to reflect the mid-points of bins + /* add .5 to reflect the mid-points of bins */ double currentY = sum / (double)num + .5; double gainRatio = referenceGain_ / currentGain; double shutterSpeedRatio = @@ -89,14 +91,16 @@ void Lux::process(StatisticsPtr &stats, Metadata *imageMetadata) std::unique_lock lock(mutex_); status_ = status; } - // Overwrite the metadata here as well, so that downstream - // algorithms get the latest value. + /* + * Overwrite the metadata here as well, so that downstream + * algorithms get the latest value. + */ imageMetadata->set("lux.status", status); } else LOG(RPiLux, Warning) << ": no device metadata"; } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return (Algorithm *)new Lux(controller); diff --git a/src/ipa/raspberrypi/controller/rpi/lux.hpp b/src/ipa/raspberrypi/controller/rpi/lux.hpp index bd49a409d402..5488299b71c1 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.hpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.hpp @@ -13,7 +13,7 @@ #include "../lux_status.h" #include "../algorithm.hpp" -// This is our implementation of the "lux control algorithm". +/* This is our implementation of the "lux control algorithm". */ namespace RPiController { @@ -28,16 +28,18 @@ public: void setCurrentAperture(double aperture); private: - // These values define the conditions of the reference image, against - // which we compare the new image. + /* + * These values define the conditions of the reference image, against + * which we compare the new image. + */ libcamera::utils::Duration referenceShutterSpeed_; double referenceGain_; - double referenceAperture_; // units of 1/f - double referenceY_; // out of 65536 + double referenceAperture_; /* units of 1/f */ + double referenceY_; /* out of 65536 */ double referenceLux_; double currentAperture_; LuxStatus status_; std::mutex mutex_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/noise.cpp b/src/ipa/raspberrypi/controller/rpi/noise.cpp index 97b0fd05e9d3..5d87822ef2b8 100644 --- a/src/ipa/raspberrypi/controller/rpi/noise.cpp +++ b/src/ipa/raspberrypi/controller/rpi/noise.cpp @@ -34,8 +34,10 @@ char const *Noise::name() const 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?) + /* + * 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?) + */ modeFactor_ = std::max(1.0, cameraMode.noiseFactor); } @@ -48,14 +50,16 @@ void Noise::read(boost::property_tree::ptree const ¶ms) void Noise::prepare(Metadata *imageMetadata) { struct DeviceStatus deviceStatus; - deviceStatus.analogueGain = 1.0; // keep compiler calm + 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... + /* + * 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(deviceStatus.analogueGain) / modeFactor_; struct NoiseStatus status; status.noiseConstant = referenceConstant_ * factor; @@ -68,7 +72,7 @@ void Noise::prepare(Metadata *imageMetadata) LOG(RPiNoise, Warning) << " no metadata"; } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return new Noise(controller); diff --git a/src/ipa/raspberrypi/controller/rpi/noise.hpp b/src/ipa/raspberrypi/controller/rpi/noise.hpp index ed6ffe910e27..56a4707b5ef2 100644 --- a/src/ipa/raspberrypi/controller/rpi/noise.hpp +++ b/src/ipa/raspberrypi/controller/rpi/noise.hpp @@ -9,7 +9,7 @@ #include "../algorithm.hpp" #include "../noise_status.h" -// This is our implementation of the "noise algorithm". +/* This is our implementation of the "noise algorithm". */ namespace RPiController { @@ -23,10 +23,10 @@ public: void prepare(Metadata *imageMetadata) override; private: - // the noise profile for analogue gain of 1.0 + /* the noise profile for analogue gain of 1.0 */ double referenceConstant_; double referenceSlope_; double modeFactor_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.cpp b/src/ipa/raspberrypi/controller/rpi/sdn.cpp index 480da38dc068..2f6b87640e13 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.cpp @@ -17,8 +17,10 @@ using namespace libcamera; LOG_DEFINE_CATEGORY(RPiSdn) -// Calculate settings for the spatial denoise block using the noise profile in -// the image metadata. +/* + * Calculate settings for the spatial denoise block using the noise profile in + * the image metadata. + */ #define NAME "rpi.sdn" @@ -45,7 +47,7 @@ void Sdn::initialise() void Sdn::prepare(Metadata *imageMetadata) { struct NoiseStatus noiseStatus = {}; - noiseStatus.noiseSlope = 3.0; // in case no metadata + noiseStatus.noiseSlope = 3.0; /* in case no metadata */ if (imageMetadata->get("noise.status", noiseStatus) != 0) LOG(RPiSdn, Warning) << "no noise profile found"; LOG(RPiSdn, Debug) @@ -65,11 +67,11 @@ void Sdn::prepare(Metadata *imageMetadata) void Sdn::setMode(DenoiseMode mode) { - // We only distinguish between off and all other modes. + /* We only distinguish between off and all other modes. */ mode_ = mode; } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return (Algorithm *)new Sdn(controller); diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.hpp b/src/ipa/raspberrypi/controller/rpi/sdn.hpp index d9b18f296635..8b6e3db1a548 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.hpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.hpp @@ -11,7 +11,7 @@ namespace RPiController { -// Algorithm to calculate correct spatial denoise (SDN) settings. +/* Algorithm to calculate correct spatial denoise (SDN) settings. */ class Sdn : public DenoiseAlgorithm { @@ -29,4 +29,4 @@ private: DenoiseMode mode_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp index 3fe62bc8a5cf..9b7f903a155e 100644 --- a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp @@ -33,7 +33,7 @@ char const *Sharpen::name() const void Sharpen::switchMode(CameraMode const &cameraMode, [[maybe_unused]] Metadata *metadata) { - // can't be less than one, right? + /* can't be less than one, right? */ modeFactor_ = std::max(1.0, cameraMode.noiseFactor); } @@ -50,24 +50,30 @@ void Sharpen::read(boost::property_tree::ptree const ¶ms) 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). + /* + * 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). + */ userStrength_ = std::max(0.0, strength); } void Sharpen::prepare(Metadata *imageMetadata) { - // The userStrength_ 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. + /* + * The userStrength_ 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 userStrengthSqrt = sqrt(userStrength_); struct SharpenStatus status; - // Binned modes seem to need the sharpening toned down with this - // pipeline, thus we use the modeFactor_ here. Also avoid - // divide-by-zero with the userStrengthSqrt. + /* + * Binned modes seem to need the sharpening toned down with this + * pipeline, thus we use the modeFactor_ here. Also avoid + * divide-by-zero with the userStrengthSqrt. + */ status.threshold = threshold_ * modeFactor_ / std::max(0.01, userStrengthSqrt); status.strength = strength_ / modeFactor_ * userStrength_; @@ -77,7 +83,7 @@ void Sharpen::prepare(Metadata *imageMetadata) imageMetadata->set("sharpen.status", status); } -// Register algorithm with the system. +/* Register algorithm with the system. */ static Algorithm *create(Controller *controller) { return new Sharpen(controller); diff --git a/src/ipa/raspberrypi/controller/rpi/sharpen.hpp b/src/ipa/raspberrypi/controller/rpi/sharpen.hpp index ced917f3c42b..18c45fd4e2a7 100644 --- a/src/ipa/raspberrypi/controller/rpi/sharpen.hpp +++ b/src/ipa/raspberrypi/controller/rpi/sharpen.hpp @@ -9,7 +9,7 @@ #include "../sharpen_algorithm.hpp" #include "../sharpen_status.h" -// This is our implementation of the "sharpen algorithm". +/* This is our implementation of the "sharpen algorithm". */ namespace RPiController { @@ -31,4 +31,4 @@ private: double userStrength_; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp b/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp index 888f4569c56a..22cc6090f8fc 100644 --- a/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp @@ -14,8 +14,8 @@ class SharpenAlgorithm : public Algorithm { public: SharpenAlgorithm(Controller *controller) : Algorithm(controller) {} - // A sharpness control algorithm must provide the following: + /* A sharpness control algorithm must provide the following: */ virtual void setStrength(double strength) = 0; }; -} // namespace RPiController +} /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/sharpen_status.h b/src/ipa/raspberrypi/controller/sharpen_status.h index 2b0490742fba..5ea21ab23f91 100644 --- a/src/ipa/raspberrypi/controller/sharpen_status.h +++ b/src/ipa/raspberrypi/controller/sharpen_status.h @@ -6,20 +6,20 @@ */ #pragma once -// The "sharpen" algorithm stores the strength to use. +/* The "sharpen" algorithm stores the strength to use. */ #ifdef __cplusplus extern "C" { #endif struct SharpenStatus { - // controls the smallest level of detail (or noise!) that sharpening will pick up + /* controls the smallest level of detail (or noise!) that sharpening will pick up */ double threshold; - // the rate at which the sharpening response ramps once above the threshold + /* the rate at which the sharpening response ramps once above the threshold */ double strength; - // upper limit of the allowed sharpening response + /* upper limit of the allowed sharpening response */ double limit; - // The sharpening strength requested by the user or application. + /* The sharpening strength requested by the user or application. */ double userStrength; }; diff --git a/src/ipa/raspberrypi/md_parser.hpp b/src/ipa/raspberrypi/md_parser.hpp index 298d51811256..c9aeed2c5405 100644 --- a/src/ipa/raspberrypi/md_parser.hpp +++ b/src/ipa/raspberrypi/md_parser.hpp @@ -152,4 +152,4 @@ private: OffsetMap offsets_; }; -} // namespace RPi +} /* namespace RPi */ From patchwork Tue Jul 26 12:45:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16784 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 BC964C3276 for ; Tue, 26 Jul 2022 12:46:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 803E26331A; Tue, 26 Jul 2022 14:46:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839573; bh=DZaxv2T17gLdbYtEhtz8H/QG4ShyhpAO0hAj8ka2Qao=; 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=zPwFM3dT6bZGQpFYVy+dEO8LAQbABY5lcnoABernrYUCWvADcJhz0yoh46McAJTH4 J5vqqnBoHA4D5/uTGaaauKTPemrpszo6PH3c8fiEIGye2k0R7tpghJGx+rrO3sHNZ4 sdSW0kmFZIAjz0peucoaN5mx6vdu6s2pSfquH5qMkZWtc5sJ1Tdt+l2z3lCrcLoIeH aEVD2k9+EHinc2WeSIOVkmL3upZ3S3J8Uxh7XOZIRh3SSNj+Ch5s66J8vEMzI219mE vZAs+emOZkgXfyfRLWWN/zxt0w3lpltDThMYROl+E3xBp2P0E5zSfC2Sdkn/uVDrWD ubSgJ8mcUfEMw== Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 921C063328 for ; Tue, 26 Jul 2022 14:46:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="EIpbsE4K"; dkim-atps=neutral Received: by mail-wm1-x32f.google.com with SMTP id id17so8680450wmb.1 for ; Tue, 26 Jul 2022 05:46:09 -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=NY7JyaOac2q2MSMD7Q38yiXfBA4PvnnhUAE6F35MFJg=; b=EIpbsE4KXQSnZiyqDNGz6N6N3xl7VKoU9hBDti7+nJGGklG9BhFXTWidhCGEumMDQj N9SPX/o435tQBWQxJyl6sfiFi1c2lR1PRdQXkTMX9s9P4rQJgQqhS/6fLBeUJVA9wUPF JsXKzcxzVE403gQ9QglkFyJ3J2ObVdXOzO0Z462RgkgBssJwHdV+YbN0in5kiUc/1wvL YRYhJjKiwTcsAhp21RnS9xUEvJaQhSnJDV5QQz9s+RuLPyq5SUQHPejstIzKyPQOwsU8 3ZhU7SuRZVKefDyHjXw4KVkwS+TuTm32jMxYskDG8K5iTOp3LgTtNjklgFpxb7XLnV/N i97A== 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=NY7JyaOac2q2MSMD7Q38yiXfBA4PvnnhUAE6F35MFJg=; b=U6OvrxJKOQYVrJ4tCioYjl9xcpWcdmczQAPLPxO8q4NasubtbkAivSi9YaW1T65Fsr pY2Ae/J+hO/zTIaJhZBn8Rdb2US24We5/nwPwxmCH07LAPFwTMCbnQlkuCgjfB0QDq9o XiTvUpJpx9ll2RREgjvuKTqPJMv5Qde0qUXDUdfL7PjnbEntEW+4H/0BNBJ6sLFziWEP 7GW8iMqRHPAE+WK7pDvWGmPtQXzrtmYAFHw5prM9DfMWDZPSw0XfyH52X1N52xVk8Npw s45ShaFT4712ikgkbZEvVEq4D3RvJqzahNhRhCySJOIKDncOvu3mHhiT46EPBckxE10a TQpQ== X-Gm-Message-State: AJIora/XzNLm9/HvqL4jWRn4ppi4b6HQkFWNILj9ucHYSxCq78PJsOAZ PqK1YoMS0WmL7IElWoQdvJ4KFhDSz45b8Q== X-Google-Smtp-Source: AGRyM1ufCLW/T25ULWifsSTRBgmnTFQdDiAr7bXIxqxfAz2W0eP6AefkUi6LtR5mCz9C1H98cl3prQ== X-Received: by 2002:a05:600c:1d22:b0:3a3:69f5:b242 with SMTP id l34-20020a05600c1d2200b003a369f5b242mr5005663wms.202.1658839568610; Tue, 26 Jul 2022 05:46:08 -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.46.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:46:08 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:44 +0100 Message-Id: <20220726124549.1646-13-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 12/17] ipa: raspberrypi: Remove extern "C" declarations 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" Since the controller header files are now C++ specific, remove the extern "C" declarations. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/agc_status.h | 8 -------- src/ipa/raspberrypi/controller/alsc_status.h | 8 -------- src/ipa/raspberrypi/controller/awb_status.h | 8 -------- src/ipa/raspberrypi/controller/black_level_status.h | 8 -------- src/ipa/raspberrypi/controller/camera_mode.h | 8 -------- src/ipa/raspberrypi/controller/ccm_status.h | 8 -------- src/ipa/raspberrypi/controller/contrast_status.h | 8 -------- src/ipa/raspberrypi/controller/denoise_status.h | 8 -------- src/ipa/raspberrypi/controller/dpc_status.h | 8 -------- src/ipa/raspberrypi/controller/focus_status.h | 8 -------- src/ipa/raspberrypi/controller/geq_status.h | 8 -------- src/ipa/raspberrypi/controller/lux_status.h | 8 -------- src/ipa/raspberrypi/controller/noise_status.h | 8 -------- src/ipa/raspberrypi/controller/sharpen_status.h | 8 -------- 14 files changed, 112 deletions(-) diff --git a/src/ipa/raspberrypi/controller/agc_status.h b/src/ipa/raspberrypi/controller/agc_status.h index 9d184a158411..c7b7c1b2d938 100644 --- a/src/ipa/raspberrypi/controller/agc_status.h +++ b/src/ipa/raspberrypi/controller/agc_status.h @@ -13,10 +13,6 @@ * "agc.status" metadata. */ -#ifdef __cplusplus -extern "C" { -#endif - /* * Note: total_exposure_value will be reported as zero until the algorithm has * seen statistics and calculated meaningful values. The contents should be @@ -39,7 +35,3 @@ struct AgcStatus { double digitalGain; int locked; }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/alsc_status.h b/src/ipa/raspberrypi/controller/alsc_status.h index e074f9359faa..d7122f5190ce 100644 --- a/src/ipa/raspberrypi/controller/alsc_status.h +++ b/src/ipa/raspberrypi/controller/alsc_status.h @@ -11,10 +11,6 @@ * "alsc.status" metadata. */ -#ifdef __cplusplus -extern "C" { -#endif - #define ALSC_CELLS_X 16 #define ALSC_CELLS_Y 12 @@ -23,7 +19,3 @@ struct AlscStatus { double g[ALSC_CELLS_Y][ALSC_CELLS_X]; double b[ALSC_CELLS_Y][ALSC_CELLS_X]; }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/awb_status.h b/src/ipa/raspberrypi/controller/awb_status.h index 2f6e88ef6e7f..353906f8aefd 100644 --- a/src/ipa/raspberrypi/controller/awb_status.h +++ b/src/ipa/raspberrypi/controller/awb_status.h @@ -11,10 +11,6 @@ * under the tag "awb.status". */ -#ifdef __cplusplus -extern "C" { -#endif - struct AwbStatus { char mode[32]; double temperatureK; @@ -22,7 +18,3 @@ struct AwbStatus { double gainG; double gainB; }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/black_level_status.h b/src/ipa/raspberrypi/controller/black_level_status.h index 8b0523834dcf..8d2c497aef3a 100644 --- a/src/ipa/raspberrypi/controller/black_level_status.h +++ b/src/ipa/raspberrypi/controller/black_level_status.h @@ -8,16 +8,8 @@ /* The "black level" algorithm stores the black levels to use. */ -#ifdef __cplusplus -extern "C" { -#endif - struct BlackLevelStatus { uint16_t blackLevelR; /* out of 16 bits */ uint16_t blackLevelG; uint16_t blackLevelB; }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h index 47a0fea424ca..6e1597d23a28 100644 --- a/src/ipa/raspberrypi/controller/camera_mode.h +++ b/src/ipa/raspberrypi/controller/camera_mode.h @@ -16,10 +16,6 @@ * including binning, scaling, cropping etc. */ -#ifdef __cplusplus -extern "C" { -#endif - #define CAMERA_MODE_NAME_LEN 32 struct CameraMode { @@ -46,7 +42,3 @@ struct CameraMode { /* sensitivity of this mode */ double sensitivity; }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/ccm_status.h b/src/ipa/raspberrypi/controller/ccm_status.h index 4cdd8bed0311..44471d0ef901 100644 --- a/src/ipa/raspberrypi/controller/ccm_status.h +++ b/src/ipa/raspberrypi/controller/ccm_status.h @@ -8,15 +8,7 @@ /* The "ccm" algorithm generates an appropriate colour matrix. */ -#ifdef __cplusplus -extern "C" { -#endif - struct CcmStatus { double matrix[9]; double saturation; }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/contrast_status.h b/src/ipa/raspberrypi/controller/contrast_status.h index 5eb084f78e71..88152575288f 100644 --- a/src/ipa/raspberrypi/controller/contrast_status.h +++ b/src/ipa/raspberrypi/controller/contrast_status.h @@ -11,10 +11,6 @@ * of contrast stretching based on the AGC histogram. */ -#ifdef __cplusplus -extern "C" { -#endif - #define CONTRAST_NUM_POINTS 33 struct ContrastPoint { @@ -27,7 +23,3 @@ struct ContrastStatus { double brightness; double contrast; }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/denoise_status.h b/src/ipa/raspberrypi/controller/denoise_status.h index c2d9c7301b19..e97368aaab54 100644 --- a/src/ipa/raspberrypi/controller/denoise_status.h +++ b/src/ipa/raspberrypi/controller/denoise_status.h @@ -8,17 +8,9 @@ /* This stores the parameters required for Denoise. */ -#ifdef __cplusplus -extern "C" { -#endif - struct DenoiseStatus { double noiseConstant; double noiseSlope; double strength; unsigned int mode; }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/dpc_status.h b/src/ipa/raspberrypi/controller/dpc_status.h index c99ad8c500a6..685ffc7b91b5 100644 --- a/src/ipa/raspberrypi/controller/dpc_status.h +++ b/src/ipa/raspberrypi/controller/dpc_status.h @@ -8,14 +8,6 @@ /* The "DPC" algorithm sets defective pixel correction strength. */ -#ifdef __cplusplus -extern "C" { -#endif - struct DpcStatus { int strength; /* 0 = "off", 1 = "normal", 2 = "strong" */ }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/focus_status.h b/src/ipa/raspberrypi/controller/focus_status.h index c75795dc0621..f0dbe4e2c4a2 100644 --- a/src/ipa/raspberrypi/controller/focus_status.h +++ b/src/ipa/raspberrypi/controller/focus_status.h @@ -14,15 +14,7 @@ * measurements, it's not driving any kind of auto-focus algorithm! */ -#ifdef __cplusplus -extern "C" { -#endif - struct FocusStatus { unsigned int num; uint32_t focusMeasures[FOCUS_REGIONS]; }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/geq_status.h b/src/ipa/raspberrypi/controller/geq_status.h index 0ebb7ce71d5b..791f34ca2e52 100644 --- a/src/ipa/raspberrypi/controller/geq_status.h +++ b/src/ipa/raspberrypi/controller/geq_status.h @@ -8,15 +8,7 @@ /* The "GEQ" algorithm calculates the green equalisation thresholds */ -#ifdef __cplusplus -extern "C" { -#endif - struct GeqStatus { uint16_t offset; double slope; }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/lux_status.h b/src/ipa/raspberrypi/controller/lux_status.h index c1134bec3694..cd5ed473c10d 100644 --- a/src/ipa/raspberrypi/controller/lux_status.h +++ b/src/ipa/raspberrypi/controller/lux_status.h @@ -17,15 +17,7 @@ * (presumably meaningless) value in the image metadata. */ -#ifdef __cplusplus -extern "C" { -#endif - struct LuxStatus { double lux; double aperture; }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/noise_status.h b/src/ipa/raspberrypi/controller/noise_status.h index 689beed394a7..843260f013ae 100644 --- a/src/ipa/raspberrypi/controller/noise_status.h +++ b/src/ipa/raspberrypi/controller/noise_status.h @@ -8,15 +8,7 @@ /* The "noise" algorithm stores an estimate of the noise profile for this image. */ -#ifdef __cplusplus -extern "C" { -#endif - struct NoiseStatus { double noiseConstant; double noiseSlope; }; - -#ifdef __cplusplus -} -#endif diff --git a/src/ipa/raspberrypi/controller/sharpen_status.h b/src/ipa/raspberrypi/controller/sharpen_status.h index 5ea21ab23f91..c66eaa73af3b 100644 --- a/src/ipa/raspberrypi/controller/sharpen_status.h +++ b/src/ipa/raspberrypi/controller/sharpen_status.h @@ -8,10 +8,6 @@ /* The "sharpen" algorithm stores the strength to use. */ -#ifdef __cplusplus -extern "C" { -#endif - struct SharpenStatus { /* controls the smallest level of detail (or noise!) that sharpening will pick up */ double threshold; @@ -22,7 +18,3 @@ struct SharpenStatus { /* The sharpening strength requested by the user or application. */ double userStrength; }; - -#ifdef __cplusplus -} -#endif From patchwork Tue Jul 26 12:45:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16785 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 D20E2C3275 for ; Tue, 26 Jul 2022 12:46:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6CBF263321; Tue, 26 Jul 2022 14:46:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839574; bh=bFsDw4prLw+LNU/tH5eEv2EqjGQoc8Xk+XfY/AOMo7Y=; 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=So2ixsifKYNULIoIYJ9E/wBZNwMbsNB9EPI9kG2gOrtNI1asm6VUC+BD34J4PGTMk BaxmG7R0bSCLEYS2yeMNRiKjarppLOIo6v1d/McuYRpoAQK8xPL0iqTU+Qk6lMB42X 3N3+fIy5f+D2ru3I1kLNmbalF+T7Wz1zXyROhliA4Kz7CaP+9aZrDlzIAYAI1C/DhD uidPB3lRl8sB8qlwCwi4L7K3CGvVZROdw9T5oWLuMZMWk6UuIwGAmyYnt3UzYQkYcX eiikFlXJFo5hUPF7eaIxVy1Fjy31XOzyfx6jS+GM3ougDcTcpNezocEv93YWZKimg4 ij4btXIzlWvnQ== Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ECBC863329 for ; Tue, 26 Jul 2022 14:46:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="V9lWlIJI"; dkim-atps=neutral Received: by mail-wr1-x430.google.com with SMTP id k11so19539168wrx.5 for ; Tue, 26 Jul 2022 05:46:10 -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=IXt4sMeFJ+Kic4wNsVzGjUBeZwmdp49lW2Mbp2cD+oU=; b=V9lWlIJIJN9Pd3N3HA78vG7+tIDWLhEbr1e52hODe2tU21AhDMdVg9M03AJYEP207R ruX7qKeXBAmWgl6XNU4bdIjq46w8SnnSGKJ9mcjnkVUPA7u+x6OOn4JAApPCNTJHJzSg ZcGYmY63kF+YLkKBZ5jnnH8XABCLlga7SmL+1vPCs+/ELtLCP24aOECvzf9XG/VE8Xul qsEnbR9tpZYJKWQ84mrbN05ue5EypXLN/hbaxCYomoI2s+QqvoYHnttclz94oslt98qm pziiBANy/ornvyr8VaLNKMB0LDP/C3v7u9GGg9ErZvYzQHaHcqRgnmbse7KCZvsqYLrV hcZw== 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=IXt4sMeFJ+Kic4wNsVzGjUBeZwmdp49lW2Mbp2cD+oU=; b=XRDVwZkn+1xP8GT6nifvU6Yo9H/D0TTSSl7KQUaZOR3meNCUCpViBJID7yKV5we9ud RoK83swvges8oSDojNNim2nnAK6hlGrtpj4NhWYC4gvyvZJHlJ/hYmiwFjnIGgNszXO4 nTKG/bXVjh2n5/1bi7cxVnpu37msjn378QdJoqSE4BhvrjhVrO1yETKgrK39baS1b9d3 oTV5cLMXomKUAJuagvqy9nNUhR8/DQVLG06+wdlFVT5wxoFlw3tShp+WR9A1B15c5bhM ROJU5hC66FeczrAyAfR6qGCXcWC+lKTxnpwQFLnYV3MXQRWfh2TK3QjDO+76vK3teftV Zhow== X-Gm-Message-State: AJIora9/wTBlHTR87DAtsyt6FmeSJkRmsHyHYRLBfV1GH0J74U6YamWE PGtXxjuOn63XtFB2byKgg07joYFHtIRd8Q== X-Google-Smtp-Source: AGRyM1tYaIqlgSJHQWLaE5XQ1TvkbU0GErpdmfUMVEVZ+rWHyk6G3jt01AuPg8Lj9PrYY+2thZEcUQ== X-Received: by 2002:a5d:6d0e:0:b0:21e:88ed:9ffc with SMTP id e14-20020a5d6d0e000000b0021e88ed9ffcmr6545255wrq.676.1658839569698; Tue, 26 Jul 2022 05:46:09 -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.46.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:46:08 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:45 +0100 Message-Id: <20220726124549.1646-14-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 13/17] ipa: raspberrypi: Rename header files from *.hpp to *.h 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" As per the libcamera coding guidelines, rename all .hpp header files to .h. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/cam_helper.cpp | 4 ++-- .../{cam_helper.hpp => cam_helper.h} | 8 ++++---- src/ipa/raspberrypi/cam_helper_imx219.cpp | 4 ++-- src/ipa/raspberrypi/cam_helper_imx290.cpp | 2 +- src/ipa/raspberrypi/cam_helper_imx296.cpp | 2 +- src/ipa/raspberrypi/cam_helper_imx477.cpp | 4 ++-- src/ipa/raspberrypi/cam_helper_imx519.cpp | 4 ++-- src/ipa/raspberrypi/cam_helper_ov5647.cpp | 2 +- src/ipa/raspberrypi/cam_helper_ov9281.cpp | 2 +- .../{agc_algorithm.hpp => agc_algorithm.h} | 4 ++-- src/ipa/raspberrypi/controller/algorithm.cpp | 2 +- .../controller/{algorithm.hpp => algorithm.h} | 4 ++-- .../{awb_algorithm.hpp => awb_algorithm.h} | 4 ++-- .../{ccm_algorithm.hpp => ccm_algorithm.h} | 4 ++-- ...rast_algorithm.hpp => contrast_algorithm.h} | 4 ++-- src/ipa/raspberrypi/controller/controller.cpp | 4 ++-- .../{controller.hpp => controller.h} | 4 ++-- ...noise_algorithm.hpp => denoise_algorithm.h} | 4 ++-- src/ipa/raspberrypi/controller/histogram.cpp | 2 +- .../controller/{histogram.hpp => histogram.h} | 2 +- .../controller/{metadata.hpp => metadata.h} | 2 +- src/ipa/raspberrypi/controller/pwl.cpp | 2 +- .../raspberrypi/controller/{pwl.hpp => pwl.h} | 2 +- src/ipa/raspberrypi/controller/rpi/agc.cpp | 6 +++--- .../controller/rpi/{agc.hpp => agc.h} | 6 +++--- src/ipa/raspberrypi/controller/rpi/alsc.cpp | 2 +- .../controller/rpi/{alsc.hpp => alsc.h} | 4 ++-- src/ipa/raspberrypi/controller/rpi/awb.cpp | 2 +- .../controller/rpi/{awb.hpp => awb.h} | 6 +++--- .../raspberrypi/controller/rpi/black_level.cpp | 2 +- .../rpi/{black_level.hpp => black_level.h} | 4 ++-- src/ipa/raspberrypi/controller/rpi/ccm.cpp | 4 ++-- .../controller/rpi/{ccm.hpp => ccm.h} | 6 +++--- .../raspberrypi/controller/rpi/contrast.cpp | 4 ++-- .../rpi/{contrast.hpp => contrast.h} | 6 +++--- src/ipa/raspberrypi/controller/rpi/dpc.cpp | 2 +- .../controller/rpi/{dpc.hpp => dpc.h} | 4 ++-- src/ipa/raspberrypi/controller/rpi/focus.cpp | 2 +- .../controller/rpi/{focus.hpp => focus.h} | 6 +++--- src/ipa/raspberrypi/controller/rpi/geq.cpp | 4 ++-- .../controller/rpi/{geq.hpp => geq.h} | 4 ++-- src/ipa/raspberrypi/controller/rpi/lux.cpp | 2 +- .../controller/rpi/{lux.hpp => lux.h} | 4 ++-- src/ipa/raspberrypi/controller/rpi/noise.cpp | 2 +- .../controller/rpi/{noise.hpp => noise.h} | 4 ++-- src/ipa/raspberrypi/controller/rpi/sdn.cpp | 2 +- .../controller/rpi/{sdn.hpp => sdn.h} | 6 +++--- src/ipa/raspberrypi/controller/rpi/sharpen.cpp | 2 +- .../controller/rpi/{sharpen.hpp => sharpen.h} | 4 ++-- ...arpen_algorithm.hpp => sharpen_algorithm.h} | 4 ++-- .../raspberrypi/{md_parser.hpp => md_parser.h} | 2 +- src/ipa/raspberrypi/md_parser_smia.cpp | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 18 +++++++++--------- 53 files changed, 101 insertions(+), 101 deletions(-) rename src/ipa/raspberrypi/{cam_helper.hpp => cam_helper.h} (96%) rename src/ipa/raspberrypi/controller/{agc_algorithm.hpp => agc_algorithm.h} (92%) rename src/ipa/raspberrypi/controller/{algorithm.hpp => algorithm.h} (95%) rename src/ipa/raspberrypi/controller/{awb_algorithm.hpp => awb_algorithm.h} (86%) rename src/ipa/raspberrypi/controller/{ccm_algorithm.hpp => ccm_algorithm.h} (78%) rename src/ipa/raspberrypi/controller/{contrast_algorithm.hpp => contrast_algorithm.h} (82%) rename src/ipa/raspberrypi/controller/{controller.hpp => controller.h} (95%) rename src/ipa/raspberrypi/controller/{denoise_algorithm.hpp => denoise_algorithm.h} (86%) rename src/ipa/raspberrypi/controller/{histogram.hpp => histogram.h} (96%) rename src/ipa/raspberrypi/controller/{metadata.hpp => metadata.h} (98%) rename src/ipa/raspberrypi/controller/{pwl.hpp => pwl.h} (98%) rename src/ipa/raspberrypi/controller/rpi/{agc.hpp => agc.h} (97%) rename src/ipa/raspberrypi/controller/rpi/{alsc.hpp => alsc.h} (97%) rename src/ipa/raspberrypi/controller/rpi/{awb.hpp => awb.h} (98%) rename src/ipa/raspberrypi/controller/rpi/{black_level.hpp => black_level.h} (88%) rename src/ipa/raspberrypi/controller/rpi/{ccm.hpp => ccm.h} (93%) rename src/ipa/raspberrypi/controller/rpi/{contrast.hpp => contrast.h} (90%) rename src/ipa/raspberrypi/controller/rpi/{dpc.hpp => dpc.h} (85%) rename src/ipa/raspberrypi/controller/rpi/{focus.hpp => focus.h} (85%) rename src/ipa/raspberrypi/controller/rpi/{geq.hpp => geq.h} (88%) rename src/ipa/raspberrypi/controller/rpi/{lux.hpp => lux.h} (94%) rename src/ipa/raspberrypi/controller/rpi/{noise.hpp => noise.h} (91%) rename src/ipa/raspberrypi/controller/rpi/{sdn.hpp => sdn.h} (84%) rename src/ipa/raspberrypi/controller/rpi/{sharpen.hpp => sharpen.h} (90%) rename src/ipa/raspberrypi/controller/{sharpen_algorithm.hpp => sharpen_algorithm.h} (82%) rename src/ipa/raspberrypi/{md_parser.hpp => md_parser.h} (98%) diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index 45db39506937..7d1369335e1d 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -13,8 +13,8 @@ #include "libcamera/internal/v4l2_videodevice.h" -#include "cam_helper.hpp" -#include "md_parser.hpp" +#include "cam_helper.h" +#include "md_parser.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/cam_helper.hpp b/src/ipa/raspberrypi/cam_helper.h similarity index 96% rename from src/ipa/raspberrypi/cam_helper.hpp rename to src/ipa/raspberrypi/cam_helper.h index 2408fa154d3d..6c52bb521b2a 100644 --- a/src/ipa/raspberrypi/cam_helper.hpp +++ b/src/ipa/raspberrypi/cam_helper.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * cam_helper.hpp - helper class providing camera information + * cam_helper.h - helper class providing camera information */ #pragma once @@ -13,9 +13,9 @@ #include #include "camera_mode.h" -#include "controller/controller.hpp" -#include "controller/metadata.hpp" -#include "md_parser.hpp" +#include "controller/controller.h" +#include "controller/metadata.h" +#include "md_parser.h" #include "libcamera/internal/v4l2_videodevice.h" diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp index 17c35143923a..47af2c35fdbc 100644 --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp @@ -16,9 +16,9 @@ */ #define ENABLE_EMBEDDED_DATA 0 -#include "cam_helper.hpp" +#include "cam_helper.h" #if ENABLE_EMBEDDED_DATA -#include "md_parser.hpp" +#include "md_parser.h" #endif using namespace RPiController; diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp index 0d9a94d8d3f6..94f07b86029e 100644 --- a/src/ipa/raspberrypi/cam_helper_imx290.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp @@ -7,7 +7,7 @@ #include -#include "cam_helper.hpp" +#include "cam_helper.h" using namespace RPiController; diff --git a/src/ipa/raspberrypi/cam_helper_imx296.cpp b/src/ipa/raspberrypi/cam_helper_imx296.cpp index 15674335fa75..3c762536f53f 100644 --- a/src/ipa/raspberrypi/cam_helper_imx296.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx296.cpp @@ -9,7 +9,7 @@ #include #include -#include "cam_helper.hpp" +#include "cam_helper.h" using namespace RPiController; using libcamera::utils::Duration; diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 0767a5e1dcc5..2f267c04dfba 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -14,8 +14,8 @@ #include -#include "cam_helper.hpp" -#include "md_parser.hpp" +#include "cam_helper.h" +#include "md_parser.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp index 1752760e64a2..ab09baab2224 100644 --- a/src/ipa/raspberrypi/cam_helper_imx519.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp @@ -15,8 +15,8 @@ #include -#include "cam_helper.hpp" -#include "md_parser.hpp" +#include "cam_helper.h" +#include "md_parser.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/cam_helper_ov5647.cpp b/src/ipa/raspberrypi/cam_helper_ov5647.cpp index 9dc3fc44e5e8..70c88484667e 100644 --- a/src/ipa/raspberrypi/cam_helper_ov5647.cpp +++ b/src/ipa/raspberrypi/cam_helper_ov5647.cpp @@ -7,7 +7,7 @@ #include -#include "cam_helper.hpp" +#include "cam_helper.h" using namespace RPiController; diff --git a/src/ipa/raspberrypi/cam_helper_ov9281.cpp b/src/ipa/raspberrypi/cam_helper_ov9281.cpp index 130450afefc7..a63a391ba017 100644 --- a/src/ipa/raspberrypi/cam_helper_ov9281.cpp +++ b/src/ipa/raspberrypi/cam_helper_ov9281.cpp @@ -7,7 +7,7 @@ #include -#include "cam_helper.hpp" +#include "cam_helper.h" using namespace RPiController; diff --git a/src/ipa/raspberrypi/controller/agc_algorithm.hpp b/src/ipa/raspberrypi/controller/agc_algorithm.h similarity index 92% rename from src/ipa/raspberrypi/controller/agc_algorithm.hpp rename to src/ipa/raspberrypi/controller/agc_algorithm.h index b718e595193b..610cf7d8454d 100644 --- a/src/ipa/raspberrypi/controller/agc_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/agc_algorithm.h @@ -2,13 +2,13 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * agc_algorithm.hpp - AGC/AEC control algorithm interface + * agc_algorithm.h - AGC/AEC control algorithm interface */ #pragma once #include -#include "algorithm.hpp" +#include "algorithm.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/algorithm.cpp b/src/ipa/raspberrypi/controller/algorithm.cpp index e3afa647bdd2..a28a02adeb0d 100644 --- a/src/ipa/raspberrypi/controller/algorithm.cpp +++ b/src/ipa/raspberrypi/controller/algorithm.cpp @@ -5,7 +5,7 @@ * algorithm.cpp - ISP control algorithms */ -#include "algorithm.hpp" +#include "algorithm.h" using namespace RPiController; diff --git a/src/ipa/raspberrypi/controller/algorithm.hpp b/src/ipa/raspberrypi/controller/algorithm.h similarity index 95% rename from src/ipa/raspberrypi/controller/algorithm.hpp rename to src/ipa/raspberrypi/controller/algorithm.h index cad7c15ba5c8..ce3ca95f65f6 100644 --- a/src/ipa/raspberrypi/controller/algorithm.hpp +++ b/src/ipa/raspberrypi/controller/algorithm.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * algorithm.hpp - ISP control algorithm interface + * algorithm.h - ISP control algorithm interface */ #pragma once @@ -15,7 +15,7 @@ #include #include -#include "controller.hpp" +#include "controller.h" #include diff --git a/src/ipa/raspberrypi/controller/awb_algorithm.hpp b/src/ipa/raspberrypi/controller/awb_algorithm.h similarity index 86% rename from src/ipa/raspberrypi/controller/awb_algorithm.hpp rename to src/ipa/raspberrypi/controller/awb_algorithm.h index 0de74fce4269..712c1aa173bd 100644 --- a/src/ipa/raspberrypi/controller/awb_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/awb_algorithm.h @@ -2,11 +2,11 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * awb_algorithm.hpp - AWB control algorithm interface + * awb_algorithm.h - AWB control algorithm interface */ #pragma once -#include "algorithm.hpp" +#include "algorithm.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/ccm_algorithm.hpp b/src/ipa/raspberrypi/controller/ccm_algorithm.h similarity index 78% rename from src/ipa/raspberrypi/controller/ccm_algorithm.hpp rename to src/ipa/raspberrypi/controller/ccm_algorithm.h index 9c7172f5782d..324eae14e17a 100644 --- a/src/ipa/raspberrypi/controller/ccm_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/ccm_algorithm.h @@ -2,11 +2,11 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * ccm_algorithm.hpp - CCM (colour correction matrix) control algorithm interface + * ccm_algorithm.h - CCM (colour correction matrix) control algorithm interface */ #pragma once -#include "algorithm.hpp" +#include "algorithm.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/contrast_algorithm.hpp b/src/ipa/raspberrypi/controller/contrast_algorithm.h similarity index 82% rename from src/ipa/raspberrypi/controller/contrast_algorithm.hpp rename to src/ipa/raspberrypi/controller/contrast_algorithm.h index 1c0562e1c4a2..eaba62150730 100644 --- a/src/ipa/raspberrypi/controller/contrast_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/contrast_algorithm.h @@ -2,11 +2,11 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * contrast_algorithm.hpp - contrast (gamma) control algorithm interface + * contrast_algorithm.h - contrast (gamma) control algorithm interface */ #pragma once -#include "algorithm.hpp" +#include "algorithm.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/controller.cpp b/src/ipa/raspberrypi/controller/controller.cpp index 6d95fa55d1e4..46229d683a3b 100644 --- a/src/ipa/raspberrypi/controller/controller.cpp +++ b/src/ipa/raspberrypi/controller/controller.cpp @@ -7,8 +7,8 @@ #include -#include "algorithm.hpp" -#include "controller.hpp" +#include "algorithm.h" +#include "controller.h" #include #include diff --git a/src/ipa/raspberrypi/controller/controller.hpp b/src/ipa/raspberrypi/controller/controller.h similarity index 95% rename from src/ipa/raspberrypi/controller/controller.hpp rename to src/ipa/raspberrypi/controller/controller.h index 29b2e8f34826..be8ae8f96288 100644 --- a/src/ipa/raspberrypi/controller/controller.hpp +++ b/src/ipa/raspberrypi/controller/controller.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * controller.hpp - ISP controller interface + * controller.h - ISP controller interface */ #pragma once @@ -19,7 +19,7 @@ #include "camera_mode.h" #include "device_status.h" -#include "metadata.hpp" +#include "metadata.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/denoise_algorithm.hpp b/src/ipa/raspberrypi/controller/denoise_algorithm.h similarity index 86% rename from src/ipa/raspberrypi/controller/denoise_algorithm.hpp rename to src/ipa/raspberrypi/controller/denoise_algorithm.h index 7004fe55b41f..15a45a417b0c 100644 --- a/src/ipa/raspberrypi/controller/denoise_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/denoise_algorithm.h @@ -2,11 +2,11 @@ /* * Copyright (C) 2021, Raspberry Pi (Trading) Limited * - * denoise.hpp - Denoise control algorithm interface + * denoise.h - Denoise control algorithm interface */ #pragma once -#include "algorithm.hpp" +#include "algorithm.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/histogram.cpp b/src/ipa/raspberrypi/controller/histogram.cpp index 91a759b53d34..f0c4adaf1f44 100644 --- a/src/ipa/raspberrypi/controller/histogram.cpp +++ b/src/ipa/raspberrypi/controller/histogram.cpp @@ -7,7 +7,7 @@ #include #include -#include "histogram.hpp" +#include "histogram.h" using namespace RPiController; diff --git a/src/ipa/raspberrypi/controller/histogram.hpp b/src/ipa/raspberrypi/controller/histogram.h similarity index 96% rename from src/ipa/raspberrypi/controller/histogram.hpp rename to src/ipa/raspberrypi/controller/histogram.h index 2ed8d9713764..33ba76c1f081 100644 --- a/src/ipa/raspberrypi/controller/histogram.hpp +++ b/src/ipa/raspberrypi/controller/histogram.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * histogram.hpp - histogram calculation interface + * histogram.h - histogram calculation interface */ #pragma once diff --git a/src/ipa/raspberrypi/controller/metadata.hpp b/src/ipa/raspberrypi/controller/metadata.h similarity index 98% rename from src/ipa/raspberrypi/controller/metadata.hpp rename to src/ipa/raspberrypi/controller/metadata.h index 9f73e61ef91f..e46d0f9fabbf 100644 --- a/src/ipa/raspberrypi/controller/metadata.hpp +++ b/src/ipa/raspberrypi/controller/metadata.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited * - * metadata.hpp - general metadata class + * metadata.h - general metadata class */ #pragma once diff --git a/src/ipa/raspberrypi/controller/pwl.cpp b/src/ipa/raspberrypi/controller/pwl.cpp index d93cd2016dcf..b02979f060f0 100644 --- a/src/ipa/raspberrypi/controller/pwl.cpp +++ b/src/ipa/raspberrypi/controller/pwl.cpp @@ -8,7 +8,7 @@ #include #include -#include "pwl.hpp" +#include "pwl.h" using namespace RPiController; diff --git a/src/ipa/raspberrypi/controller/pwl.hpp b/src/ipa/raspberrypi/controller/pwl.h similarity index 98% rename from src/ipa/raspberrypi/controller/pwl.hpp rename to src/ipa/raspberrypi/controller/pwl.h index e409c966baa0..128990c5ca6c 100644 --- a/src/ipa/raspberrypi/controller/pwl.hpp +++ b/src/ipa/raspberrypi/controller/pwl.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * pwl.hpp - piecewise linear functions interface + * pwl.h - piecewise linear functions interface */ #pragma once diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index d7effebb0490..0c66e1c4758c 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -13,11 +13,11 @@ #include "../awb_status.h" #include "../device_status.h" -#include "../histogram.hpp" +#include "../histogram.h" #include "../lux_status.h" -#include "../metadata.hpp" +#include "../metadata.h" -#include "agc.hpp" +#include "agc.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/controller/rpi/agc.hpp b/src/ipa/raspberrypi/controller/rpi/agc.h similarity index 97% rename from src/ipa/raspberrypi/controller/rpi/agc.hpp rename to src/ipa/raspberrypi/controller/rpi/agc.h index c2d68b60f15e..d6b19d6f4112 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * agc.hpp - AGC/AEC control algorithm + * agc.h - AGC/AEC control algorithm */ #pragma once @@ -11,9 +11,9 @@ #include -#include "../agc_algorithm.hpp" +#include "../agc_algorithm.h" #include "../agc_status.h" -#include "../pwl.hpp" +#include "../pwl.h" /* This is our implementation of AGC. */ diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp index 6fd95a312411..709e069d689f 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp @@ -12,7 +12,7 @@ #include #include "../awb_status.h" -#include "alsc.hpp" +#include "alsc.h" /* Raspberry Pi ALSC (Auto Lens Shading Correction) algorithm. */ diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.hpp b/src/ipa/raspberrypi/controller/rpi/alsc.h similarity index 97% rename from src/ipa/raspberrypi/controller/rpi/alsc.hpp rename to src/ipa/raspberrypi/controller/rpi/alsc.h index 3ffc175d78b6..1ee88a663d31 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * alsc.hpp - ALSC (auto lens shading correction) control algorithm + * alsc.h - ALSC (auto lens shading correction) control algorithm */ #pragma once @@ -10,7 +10,7 @@ #include #include -#include "../algorithm.hpp" +#include "../algorithm.h" #include "../alsc_status.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index 4a7bc869cee4..eea255b2b14e 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp @@ -9,7 +9,7 @@ #include "../lux_status.h" -#include "awb.hpp" +#include "awb.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp b/src/ipa/raspberrypi/controller/rpi/awb.h similarity index 98% rename from src/ipa/raspberrypi/controller/rpi/awb.hpp rename to src/ipa/raspberrypi/controller/rpi/awb.h index 597f3182da44..2f7a88acebcb 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.hpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * awb.hpp - AWB control algorithm + * awb.h - AWB control algorithm */ #pragma once @@ -10,8 +10,8 @@ #include #include -#include "../awb_algorithm.hpp" -#include "../pwl.hpp" +#include "../awb_algorithm.h" +#include "../pwl.h" #include "../awb_status.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.cpp b/src/ipa/raspberrypi/controller/rpi/black_level.cpp index 4432faa6485a..5bc6a4986256 100644 --- a/src/ipa/raspberrypi/controller/rpi/black_level.cpp +++ b/src/ipa/raspberrypi/controller/rpi/black_level.cpp @@ -12,7 +12,7 @@ #include "../black_level_status.h" -#include "black_level.hpp" +#include "black_level.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.hpp b/src/ipa/raspberrypi/controller/rpi/black_level.h similarity index 88% rename from src/ipa/raspberrypi/controller/rpi/black_level.hpp rename to src/ipa/raspberrypi/controller/rpi/black_level.h index f01c55151288..ecb83e35dfdd 100644 --- a/src/ipa/raspberrypi/controller/rpi/black_level.hpp +++ b/src/ipa/raspberrypi/controller/rpi/black_level.h @@ -2,11 +2,11 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * black_level.hpp - black level control algorithm + * black_level.h - black level control algorithm */ #pragma once -#include "../algorithm.hpp" +#include "../algorithm.h" #include "../black_level_status.h" /* This is our implementation of the "black level algorithm". */ diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.cpp b/src/ipa/raspberrypi/controller/rpi/ccm.cpp index 9ad63b6e20d9..a81358d5b6d2 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.cpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.cpp @@ -10,9 +10,9 @@ #include "../awb_status.h" #include "../ccm_status.h" #include "../lux_status.h" -#include "../metadata.hpp" +#include "../metadata.h" -#include "ccm.hpp" +#include "ccm.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.hpp b/src/ipa/raspberrypi/controller/rpi/ccm.h similarity index 93% rename from src/ipa/raspberrypi/controller/rpi/ccm.hpp rename to src/ipa/raspberrypi/controller/rpi/ccm.h index 7622044ce49c..57c3518e7490 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.hpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.h @@ -2,14 +2,14 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * ccm.hpp - CCM (colour correction matrix) control algorithm + * ccm.h - CCM (colour correction matrix) control algorithm */ #pragma once #include -#include "../ccm_algorithm.hpp" -#include "../pwl.hpp" +#include "../ccm_algorithm.h" +#include "../pwl.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.cpp b/src/ipa/raspberrypi/controller/rpi/contrast.cpp index f11c834a0192..3e0177345119 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.cpp +++ b/src/ipa/raspberrypi/controller/rpi/contrast.cpp @@ -9,9 +9,9 @@ #include #include "../contrast_status.h" -#include "../histogram.hpp" +#include "../histogram.h" -#include "contrast.hpp" +#include "contrast.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.hpp b/src/ipa/raspberrypi/controller/rpi/contrast.h similarity index 90% rename from src/ipa/raspberrypi/controller/rpi/contrast.hpp rename to src/ipa/raspberrypi/controller/rpi/contrast.h index 4793dedc10ff..4568e087008f 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.hpp +++ b/src/ipa/raspberrypi/controller/rpi/contrast.h @@ -2,14 +2,14 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * contrast.hpp - contrast (gamma) control algorithm + * contrast.h - contrast (gamma) control algorithm */ #pragma once #include -#include "../contrast_algorithm.hpp" -#include "../pwl.hpp" +#include "../contrast_algorithm.h" +#include "../pwl.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.cpp b/src/ipa/raspberrypi/controller/rpi/dpc.cpp index 68ba5e3e37bb..af3c88d7ac3a 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/dpc.cpp @@ -7,7 +7,7 @@ #include -#include "dpc.hpp" +#include "dpc.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.hpp b/src/ipa/raspberrypi/controller/rpi/dpc.h similarity index 85% rename from src/ipa/raspberrypi/controller/rpi/dpc.hpp rename to src/ipa/raspberrypi/controller/rpi/dpc.h index 048fa2b8405e..d3fce5e37dd2 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.hpp +++ b/src/ipa/raspberrypi/controller/rpi/dpc.h @@ -2,11 +2,11 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * dpc.hpp - DPC (defective pixel correction) control algorithm + * dpc.h - DPC (defective pixel correction) control algorithm */ #pragma once -#include "../algorithm.hpp" +#include "../algorithm.h" #include "../dpc_status.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/rpi/focus.cpp b/src/ipa/raspberrypi/controller/rpi/focus.cpp index 90f36e58f28c..22f376b74fbf 100644 --- a/src/ipa/raspberrypi/controller/rpi/focus.cpp +++ b/src/ipa/raspberrypi/controller/rpi/focus.cpp @@ -9,7 +9,7 @@ #include #include "../focus_status.h" -#include "focus.hpp" +#include "focus.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/controller/rpi/focus.hpp b/src/ipa/raspberrypi/controller/rpi/focus.h similarity index 85% rename from src/ipa/raspberrypi/controller/rpi/focus.hpp rename to src/ipa/raspberrypi/controller/rpi/focus.h index a9207eb3cc23..3b71d686bfb8 100644 --- a/src/ipa/raspberrypi/controller/rpi/focus.hpp +++ b/src/ipa/raspberrypi/controller/rpi/focus.h @@ -2,12 +2,12 @@ /* * Copyright (C) 2020, Raspberry Pi (Trading) Limited * - * focus.hpp - focus algorithm + * focus.h - focus algorithm */ #pragma once -#include "../algorithm.hpp" -#include "../metadata.hpp" +#include "../algorithm.h" +#include "../metadata.h" /* * The "focus" algorithm. All it does it print out a version of the diff --git a/src/ipa/raspberrypi/controller/rpi/geq.cpp b/src/ipa/raspberrypi/controller/rpi/geq.cpp index 14f226cf989c..1a94c45e16fa 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.cpp +++ b/src/ipa/raspberrypi/controller/rpi/geq.cpp @@ -9,9 +9,9 @@ #include "../device_status.h" #include "../lux_status.h" -#include "../pwl.hpp" +#include "../pwl.h" -#include "geq.hpp" +#include "geq.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/controller/rpi/geq.hpp b/src/ipa/raspberrypi/controller/rpi/geq.h similarity index 88% rename from src/ipa/raspberrypi/controller/rpi/geq.hpp rename to src/ipa/raspberrypi/controller/rpi/geq.h index 5ea424fc768d..54f72cce0721 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.hpp +++ b/src/ipa/raspberrypi/controller/rpi/geq.h @@ -2,11 +2,11 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * geq.hpp - GEQ (green equalisation) control algorithm + * geq.h - GEQ (green equalisation) control algorithm */ #pragma once -#include "../algorithm.hpp" +#include "../algorithm.h" #include "../geq_status.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/rpi/lux.cpp b/src/ipa/raspberrypi/controller/rpi/lux.cpp index a76ec7296def..218ded7dc5fd 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -12,7 +12,7 @@ #include "../device_status.h" -#include "lux.hpp" +#include "lux.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/controller/rpi/lux.hpp b/src/ipa/raspberrypi/controller/rpi/lux.h similarity index 94% rename from src/ipa/raspberrypi/controller/rpi/lux.hpp rename to src/ipa/raspberrypi/controller/rpi/lux.h index 5488299b71c1..530470c22ce5 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.hpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * lux.hpp - Lux control algorithm + * lux.h - Lux control algorithm */ #pragma once @@ -11,7 +11,7 @@ #include #include "../lux_status.h" -#include "../algorithm.hpp" +#include "../algorithm.h" /* This is our implementation of the "lux control algorithm". */ diff --git a/src/ipa/raspberrypi/controller/rpi/noise.cpp b/src/ipa/raspberrypi/controller/rpi/noise.cpp index 5d87822ef2b8..aaaafe6b8699 100644 --- a/src/ipa/raspberrypi/controller/rpi/noise.cpp +++ b/src/ipa/raspberrypi/controller/rpi/noise.cpp @@ -12,7 +12,7 @@ #include "../device_status.h" #include "../noise_status.h" -#include "noise.hpp" +#include "noise.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/controller/rpi/noise.hpp b/src/ipa/raspberrypi/controller/rpi/noise.h similarity index 91% rename from src/ipa/raspberrypi/controller/rpi/noise.hpp rename to src/ipa/raspberrypi/controller/rpi/noise.h index 56a4707b5ef2..cf56fafef405 100644 --- a/src/ipa/raspberrypi/controller/rpi/noise.hpp +++ b/src/ipa/raspberrypi/controller/rpi/noise.h @@ -2,11 +2,11 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * noise.hpp - Noise control algorithm + * noise.h - Noise control algorithm */ #pragma once -#include "../algorithm.hpp" +#include "../algorithm.h" #include "../noise_status.h" /* This is our implementation of the "noise algorithm". */ diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.cpp b/src/ipa/raspberrypi/controller/rpi/sdn.cpp index 2f6b87640e13..4fe1da33d46b 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.cpp @@ -10,7 +10,7 @@ #include "../denoise_status.h" #include "../noise_status.h" -#include "sdn.hpp" +#include "sdn.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.hpp b/src/ipa/raspberrypi/controller/rpi/sdn.h similarity index 84% rename from src/ipa/raspberrypi/controller/rpi/sdn.hpp rename to src/ipa/raspberrypi/controller/rpi/sdn.h index 8b6e3db1a548..72d9d3fff917 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.hpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.h @@ -2,12 +2,12 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * sdn.hpp - SDN (spatial denoise) control algorithm + * sdn.h - SDN (spatial denoise) control algorithm */ #pragma once -#include "../algorithm.hpp" -#include "../denoise_algorithm.hpp" +#include "../algorithm.h" +#include "../denoise_algorithm.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp index 9b7f903a155e..71c8e529cd25 100644 --- a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp @@ -11,7 +11,7 @@ #include "../sharpen_status.h" -#include "sharpen.hpp" +#include "sharpen.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/controller/rpi/sharpen.hpp b/src/ipa/raspberrypi/controller/rpi/sharpen.h similarity index 90% rename from src/ipa/raspberrypi/controller/rpi/sharpen.hpp rename to src/ipa/raspberrypi/controller/rpi/sharpen.h index 18c45fd4e2a7..643fb94e8b9a 100644 --- a/src/ipa/raspberrypi/controller/rpi/sharpen.hpp +++ b/src/ipa/raspberrypi/controller/rpi/sharpen.h @@ -2,11 +2,11 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * sharpen.hpp - sharpening control algorithm + * sharpen.h - sharpening control algorithm */ #pragma once -#include "../sharpen_algorithm.hpp" +#include "../sharpen_algorithm.h" #include "../sharpen_status.h" /* This is our implementation of the "sharpen algorithm". */ diff --git a/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp b/src/ipa/raspberrypi/controller/sharpen_algorithm.h similarity index 82% rename from src/ipa/raspberrypi/controller/sharpen_algorithm.hpp rename to src/ipa/raspberrypi/controller/sharpen_algorithm.h index 22cc6090f8fc..3f585f64edcb 100644 --- a/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/sharpen_algorithm.h @@ -2,11 +2,11 @@ /* * Copyright (C) 2020, Raspberry Pi (Trading) Limited * - * sharpen_algorithm.hpp - sharpness control algorithm interface + * sharpen_algorithm.h - sharpness control algorithm interface */ #pragma once -#include "algorithm.hpp" +#include "algorithm.h" namespace RPiController { diff --git a/src/ipa/raspberrypi/md_parser.hpp b/src/ipa/raspberrypi/md_parser.h similarity index 98% rename from src/ipa/raspberrypi/md_parser.hpp rename to src/ipa/raspberrypi/md_parser.h index c9aeed2c5405..1cb461cb3db7 100644 --- a/src/ipa/raspberrypi/md_parser.hpp +++ b/src/ipa/raspberrypi/md_parser.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Raspberry Pi (Trading) Limited * - * md_parser.hpp - image sensor metadata parser interface + * md_parser.h - image sensor metadata parser interface */ #pragma once diff --git a/src/ipa/raspberrypi/md_parser_smia.cpp b/src/ipa/raspberrypi/md_parser_smia.cpp index 9fab6594baac..4ea4bc3dd400 100644 --- a/src/ipa/raspberrypi/md_parser_smia.cpp +++ b/src/ipa/raspberrypi/md_parser_smia.cpp @@ -6,7 +6,7 @@ */ #include -#include "md_parser.hpp" +#include "md_parser.h" using namespace RPiController; using namespace libcamera; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index f315ebcd4c6b..282257171e15 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -29,27 +29,27 @@ #include "libcamera/internal/mapped_framebuffer.h" -#include "agc_algorithm.hpp" +#include "agc_algorithm.h" #include "agc_status.h" #include "alsc_status.h" -#include "awb_algorithm.hpp" +#include "awb_algorithm.h" #include "awb_status.h" #include "black_level_status.h" -#include "cam_helper.hpp" -#include "ccm_algorithm.hpp" +#include "cam_helper.h" +#include "ccm_algorithm.h" #include "ccm_status.h" -#include "contrast_algorithm.hpp" +#include "contrast_algorithm.h" #include "contrast_status.h" -#include "controller.hpp" -#include "denoise_algorithm.hpp" +#include "controller.h" +#include "denoise_algorithm.h" #include "denoise_status.h" #include "dpc_status.h" #include "focus_status.h" #include "geq_status.h" #include "lux_status.h" -#include "metadata.hpp" +#include "metadata.h" #include "noise_status.h" -#include "sharpen_algorithm.hpp" +#include "sharpen_algorithm.h" #include "sharpen_status.h" namespace libcamera { From patchwork Tue Jul 26 12:45:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16787 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 302B0C3276 for ; Tue, 26 Jul 2022 12:46:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E0D2E6333D; Tue, 26 Jul 2022 14:46:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839577; bh=at7XfP8hXqvlAYbCM3ZWltJtdpliHMrzTFXm4sndrkA=; 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=tpZdtxGyC5cckfa4rDBBphawAu+q7fRHCLkg4L8WezkIKrkn0IRHyWHYw0a7V6k6d D088F/QPu82aTjK/H5PaHtVZtZTajvf4eSrubf7GlXo1f/ADoi84rrFhNNhTD0J9ST gcg10RJa14Wej0y30OEyLhykga8FNNqSsAd0E5EgzcDKpbxCwALw1jmPmMWtp30AbQ ILIzkVY1UrFhc6ohaSgkuxECZbsHtbXN72LQbTu9MtSLRGP193Qnvv44eR9j58jXL3 94Hcrjw4+6hM5GhfnqsQW3BY3aVJgZk6Wijyw2g7ipeaGxNrT12ll8oTAfZeOa/qMN U6k1FuCGaeO2g== Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 44C2463328 for ; Tue, 26 Jul 2022 14:46:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="iUe9j069"; dkim-atps=neutral Received: by mail-wm1-x331.google.com with SMTP id b21-20020a05600c4e1500b003a32bc8612fso8093733wmq.3 for ; Tue, 26 Jul 2022 05:46:12 -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=g21MAnNC2z1yHF/6hoeL9ichQ2/D8ipj2WdAVnoROAo=; b=iUe9j069hCPADsosFSS964NVOt63pNj7DFbJpza1+bEw1uM4lL6PN4pMQMR/en3M/l +EJeG6hg/b0QAji3rVoZx+Yzdquy7UE8vYxvasGUpvBWu4k8qq9sluRPE6GOpKyLJ87X Ih3Vx+EgJngYCvlvTUcU4LYlxyM6ChtxG+Ek+HaMnS55k+/GzaU1luersuZx5Oin5YDx /MUvCP9FZk2wPBBQtZeq4SfWjibW7z3CjEk0Wqr5VOypXy+EgTs1en3CLAMRJjjwECrl DHaxrgrriPkyy47KyDsk4fl2sll6FUOkuJQjzVVYIJrlI3NYXESpF/Ffd1ReGWeQhurP 4MmQ== 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=g21MAnNC2z1yHF/6hoeL9ichQ2/D8ipj2WdAVnoROAo=; b=B+iaRoHKUE+vJis0ZzWW+XhbctUfpENyv/DnOo7XGo3D6cf3VruT1oydkWPqDeh57v Va/fBAnqUtiUc0ytdf87wE3vZzUhrvlRNj0Is3/pkPdM2gqFa/dWydf8K3B2ksrBbQ3y ZDDT5Dbkc8SF63ZJpGIO97+wI8UKuU0vYtAdUNpT94Uq869QBNlZ8bVa1/1UPJnMejLF Gh6WqFPPYqquAhp2tyKUoWea/5lDIKjqpEWrdf6YUH+jssz77b16jx6ZJbAPBongqwwO P42OnZ1v3JwJ3cASH4NZUhw2V8cIs85oIpzagdbnHw+tpQw3idYz2ENkiXlb5POdX0FZ r/Gg== X-Gm-Message-State: AJIora/ZOVYGHkgyiZW/FXA5fmGa6Zs8QWN9Ofu8b59ysaFkD/EaIV5h kfaxRrMcFtBLbJJfpu1fbmHjSKinMNABng== X-Google-Smtp-Source: AGRyM1tUEJB/h8LO+oNNqoTtPq/slakpu7TRAZmY0oepjMHGbFW266su4nnizUNuEspfVj8z4b6aJQ== X-Received: by 2002:a05:600c:2d07:b0:3a3:585:5d96 with SMTP id x7-20020a05600c2d0700b003a305855d96mr11998234wmf.38.1658839570678; Tue, 26 Jul 2022 05:46:10 -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.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:46:10 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:46 +0100 Message-Id: <20220726124549.1646-15-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 14/17] raspberrypi: Update Copyright statement in all Raspberry Pi source files 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" s/Raspberry Pi (Trading) Limited/Raspberry Pi Ltd/ to reflect the new Raspberry Pi entity name. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- .reuse/dep5 | 2 +- include/libcamera/color_space.h | 2 +- include/libcamera/internal/bayer_format.h | 2 +- include/libcamera/internal/delayed_controls.h | 2 +- include/libcamera/internal/v4l2_pixelformat.h | 2 +- include/libcamera/transform.h | 2 +- include/linux/bcm2835-isp.h | 2 +- src/cam/stream_options.cpp | 2 +- src/cam/stream_options.h | 2 +- src/ipa/libipa/histogram.cpp | 2 +- src/ipa/libipa/histogram.h | 2 +- src/ipa/raspberrypi/cam_helper.cpp | 2 +- src/ipa/raspberrypi/cam_helper.h | 2 +- src/ipa/raspberrypi/cam_helper_imx219.cpp | 2 +- src/ipa/raspberrypi/cam_helper_imx290.cpp | 2 +- src/ipa/raspberrypi/cam_helper_imx296.cpp | 2 +- src/ipa/raspberrypi/cam_helper_imx477.cpp | 2 +- src/ipa/raspberrypi/cam_helper_imx519.cpp | 2 +- src/ipa/raspberrypi/cam_helper_ov5647.cpp | 2 +- src/ipa/raspberrypi/cam_helper_ov9281.cpp | 2 +- src/ipa/raspberrypi/controller/agc_algorithm.h | 2 +- src/ipa/raspberrypi/controller/agc_status.h | 2 +- src/ipa/raspberrypi/controller/algorithm.cpp | 2 +- src/ipa/raspberrypi/controller/algorithm.h | 2 +- src/ipa/raspberrypi/controller/alsc_status.h | 2 +- src/ipa/raspberrypi/controller/awb_algorithm.h | 2 +- src/ipa/raspberrypi/controller/awb_status.h | 2 +- src/ipa/raspberrypi/controller/black_level_status.h | 2 +- src/ipa/raspberrypi/controller/camera_mode.h | 2 +- src/ipa/raspberrypi/controller/ccm_algorithm.h | 2 +- src/ipa/raspberrypi/controller/ccm_status.h | 2 +- src/ipa/raspberrypi/controller/contrast_algorithm.h | 2 +- src/ipa/raspberrypi/controller/contrast_status.h | 2 +- src/ipa/raspberrypi/controller/controller.cpp | 2 +- src/ipa/raspberrypi/controller/controller.h | 2 +- src/ipa/raspberrypi/controller/denoise_algorithm.h | 2 +- src/ipa/raspberrypi/controller/denoise_status.h | 2 +- src/ipa/raspberrypi/controller/device_status.cpp | 2 +- src/ipa/raspberrypi/controller/device_status.h | 2 +- src/ipa/raspberrypi/controller/dpc_status.h | 2 +- src/ipa/raspberrypi/controller/focus_status.h | 2 +- src/ipa/raspberrypi/controller/geq_status.h | 2 +- src/ipa/raspberrypi/controller/histogram.cpp | 2 +- src/ipa/raspberrypi/controller/histogram.h | 2 +- src/ipa/raspberrypi/controller/lux_status.h | 2 +- src/ipa/raspberrypi/controller/metadata.h | 2 +- src/ipa/raspberrypi/controller/noise_status.h | 2 +- src/ipa/raspberrypi/controller/pwl.cpp | 2 +- src/ipa/raspberrypi/controller/pwl.h | 2 +- src/ipa/raspberrypi/controller/rpi/agc.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/agc.h | 2 +- src/ipa/raspberrypi/controller/rpi/alsc.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/alsc.h | 2 +- src/ipa/raspberrypi/controller/rpi/awb.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/awb.h | 2 +- src/ipa/raspberrypi/controller/rpi/black_level.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/black_level.h | 2 +- src/ipa/raspberrypi/controller/rpi/ccm.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/ccm.h | 2 +- src/ipa/raspberrypi/controller/rpi/contrast.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/contrast.h | 2 +- src/ipa/raspberrypi/controller/rpi/dpc.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/dpc.h | 2 +- src/ipa/raspberrypi/controller/rpi/focus.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/focus.h | 2 +- src/ipa/raspberrypi/controller/rpi/geq.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/geq.h | 2 +- src/ipa/raspberrypi/controller/rpi/lux.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/lux.h | 2 +- src/ipa/raspberrypi/controller/rpi/noise.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/noise.h | 2 +- src/ipa/raspberrypi/controller/rpi/sdn.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/sdn.h | 2 +- src/ipa/raspberrypi/controller/rpi/sharpen.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/sharpen.h | 2 +- src/ipa/raspberrypi/controller/sharpen_algorithm.h | 2 +- src/ipa/raspberrypi/controller/sharpen_status.h | 2 +- src/ipa/raspberrypi/md_parser.h | 2 +- src/ipa/raspberrypi/md_parser_smia.cpp | 2 +- src/ipa/raspberrypi/raspberrypi.cpp | 2 +- src/libcamera/bayer_format.cpp | 2 +- src/libcamera/color_space.cpp | 2 +- src/libcamera/delayed_controls.cpp | 2 +- src/libcamera/pipeline/raspberrypi/dma_heaps.cpp | 2 +- src/libcamera/pipeline/raspberrypi/dma_heaps.h | 2 +- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 2 +- src/libcamera/pipeline/raspberrypi/rpi_stream.cpp | 2 +- src/libcamera/pipeline/raspberrypi/rpi_stream.h | 2 +- src/libcamera/transform.cpp | 2 +- src/libcamera/v4l2_pixelformat.cpp | 2 +- src/qcam/dng_writer.cpp | 2 +- src/qcam/dng_writer.h | 2 +- utils/raspberrypi/ctt/ctt.py | 2 +- utils/raspberrypi/ctt/ctt_alsc.py | 2 +- utils/raspberrypi/ctt/ctt_awb.py | 2 +- utils/raspberrypi/ctt/ctt_ccm.py | 2 +- utils/raspberrypi/ctt/ctt_geq.py | 2 +- utils/raspberrypi/ctt/ctt_image_load.py | 2 +- utils/raspberrypi/ctt/ctt_lux.py | 2 +- utils/raspberrypi/ctt/ctt_macbeth_locator.py | 2 +- utils/raspberrypi/ctt/ctt_noise.py | 2 +- utils/raspberrypi/ctt/ctt_pretty_print_json.py | 2 +- utils/raspberrypi/ctt/ctt_ransac.py | 2 +- utils/raspberrypi/ctt/ctt_tools.py | 2 +- 104 files changed, 104 insertions(+), 104 deletions(-) diff --git a/.reuse/dep5 b/.reuse/dep5 index 96fefbe24bb8..337b069d277d 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -6,7 +6,7 @@ Source: https://git.libcamera.org/libcamera/libcamera.git/ Files: src/ipa/raspberrypi/data/*.json utils/raspberrypi/ctt/ctt_config_example.json utils/raspberrypi/ctt/ctt_ref.pgm -Copyright: 2019-2020 Raspberry Pi (Trading) Ltd. +Copyright: 2019-2020 Raspberry Pi Ltd License: BSD-2-Clause Files: src/qcam/assets/feathericons/*.svg diff --git a/include/libcamera/color_space.h b/include/libcamera/color_space.h index 086c56c1b61a..0d39fbc02220 100644 --- a/include/libcamera/color_space.h +++ b/include/libcamera/color_space.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2021, Raspberry Pi (Trading) Limited + * Copyright (C) 2021, Raspberry Pi Ltd * * color_space.h - color space definitions */ diff --git a/include/libcamera/internal/bayer_format.h b/include/libcamera/internal/bayer_format.h index 7d3e37c67e9c..78ba3969913d 100644 --- a/include/libcamera/internal/bayer_format.h +++ b/include/libcamera/internal/bayer_format.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2020, Raspberry Pi Ltd * * bayer_format.h - Bayer Pixel Format */ diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h index cd3ca8070278..aef37077103c 100644 --- a/include/libcamera/internal/delayed_controls.h +++ b/include/libcamera/internal/delayed_controls.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2020, Raspberry Pi Ltd * * delayed_controls.h - Helper to deal with controls that take effect with a delay */ diff --git a/include/libcamera/internal/v4l2_pixelformat.h b/include/libcamera/internal/v4l2_pixelformat.h index fb2d5d0b93df..7bd3ea79428f 100644 --- a/include/libcamera/internal/v4l2_pixelformat.h +++ b/include/libcamera/internal/v4l2_pixelformat.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright (C) 2019, Google Inc. - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2020, Raspberry Pi Ltd * * v4l2_pixelformat.h - V4L2 Pixel Format */ diff --git a/include/libcamera/transform.h b/include/libcamera/transform.h index 2e76b9405b2e..2a6838c78369 100644 --- a/include/libcamera/transform.h +++ b/include/libcamera/transform.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2020, Raspberry Pi Ltd * * transform.h - 2D plane transforms */ diff --git a/include/linux/bcm2835-isp.h b/include/linux/bcm2835-isp.h index 94c3af947883..5f0f78e3e93f 100644 --- a/include/linux/bcm2835-isp.h +++ b/include/linux/bcm2835-isp.h @@ -4,7 +4,7 @@ * * BCM2835 ISP driver - user space header file. * - * Copyright © 2019-2020 Raspberry Pi (Trading) Ltd. + * Copyright © 2019-2020 Raspberry Pi Ltd * * Author: Naushir Patuck (naush@raspberrypi.com) * diff --git a/src/cam/stream_options.cpp b/src/cam/stream_options.cpp index 150bd27caecf..a68135a9ed88 100644 --- a/src/cam/stream_options.cpp +++ b/src/cam/stream_options.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2020, Raspberry Pi Ltd * * stream_options.cpp - Helper to parse options for streams */ diff --git a/src/cam/stream_options.h b/src/cam/stream_options.h index d235b77fb38f..35e4e7c05fc2 100644 --- a/src/cam/stream_options.h +++ b/src/cam/stream_options.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2020, Raspberry Pi Ltd * * stream_options.h - Helper to parse options for streams */ diff --git a/src/ipa/libipa/histogram.cpp b/src/ipa/libipa/histogram.cpp index d8ad1c892477..69b461779a1f 100644 --- a/src/ipa/libipa/histogram.cpp +++ b/src/ipa/libipa/histogram.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * histogram.cpp - histogram calculations */ diff --git a/src/ipa/libipa/histogram.h b/src/ipa/libipa/histogram.h index 164d4603395e..05bb4b80c43d 100644 --- a/src/ipa/libipa/histogram.h +++ b/src/ipa/libipa/histogram.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * histogram.h - histogram calculation interface */ diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp index 7d1369335e1d..37b66198dbe2 100644 --- a/src/ipa/raspberrypi/cam_helper.cpp +++ b/src/ipa/raspberrypi/cam_helper.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * cam_helper.cpp - helper information for different sensors */ diff --git a/src/ipa/raspberrypi/cam_helper.h b/src/ipa/raspberrypi/cam_helper.h index 6c52bb521b2a..70d62719da86 100644 --- a/src/ipa/raspberrypi/cam_helper.h +++ b/src/ipa/raspberrypi/cam_helper.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * cam_helper.h - helper class providing camera information */ diff --git a/src/ipa/raspberrypi/cam_helper_imx219.cpp b/src/ipa/raspberrypi/cam_helper_imx219.cpp index 47af2c35fdbc..7ded07a213cd 100644 --- a/src/ipa/raspberrypi/cam_helper_imx219.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx219.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * cam_helper_imx219.cpp - camera helper for imx219 sensor */ diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp index 94f07b86029e..25f23d531c72 100644 --- a/src/ipa/raspberrypi/cam_helper_imx290.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2021, Raspberry Pi (Trading) Limited + * Copyright (C) 2021, Raspberry Pi Ltd * * cam_helper_imx290.cpp - camera helper for imx290 sensor */ diff --git a/src/ipa/raspberrypi/cam_helper_imx296.cpp b/src/ipa/raspberrypi/cam_helper_imx296.cpp index 3c762536f53f..ab1d157aaf45 100644 --- a/src/ipa/raspberrypi/cam_helper_imx296.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx296.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2020, Raspberry Pi Ltd * * cam_helper_imx296.cpp - Camera helper for IMX296 sensor */ diff --git a/src/ipa/raspberrypi/cam_helper_imx477.cpp b/src/ipa/raspberrypi/cam_helper_imx477.cpp index 2f267c04dfba..aa306d6661c6 100644 --- a/src/ipa/raspberrypi/cam_helper_imx477.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx477.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2020, Raspberry Pi Ltd * * cam_helper_imx477.cpp - camera helper for imx477 sensor */ diff --git a/src/ipa/raspberrypi/cam_helper_imx519.cpp b/src/ipa/raspberrypi/cam_helper_imx519.cpp index ab09baab2224..54e104e7659a 100644 --- a/src/ipa/raspberrypi/cam_helper_imx519.cpp +++ b/src/ipa/raspberrypi/cam_helper_imx519.cpp @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* * Based on cam_helper_imx477.cpp - * Copyright (C) 2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2020, Raspberry Pi Ltd * * cam_helper_imx519.cpp - camera helper for imx519 sensor * Copyright (C) 2021, Arducam Technology co., Ltd. diff --git a/src/ipa/raspberrypi/cam_helper_ov5647.cpp b/src/ipa/raspberrypi/cam_helper_ov5647.cpp index 70c88484667e..04fb725d42db 100644 --- a/src/ipa/raspberrypi/cam_helper_ov5647.cpp +++ b/src/ipa/raspberrypi/cam_helper_ov5647.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * cam_helper_ov5647.cpp - camera information for ov5647 sensor */ diff --git a/src/ipa/raspberrypi/cam_helper_ov9281.cpp b/src/ipa/raspberrypi/cam_helper_ov9281.cpp index a63a391ba017..66f56a31e1b8 100644 --- a/src/ipa/raspberrypi/cam_helper_ov9281.cpp +++ b/src/ipa/raspberrypi/cam_helper_ov9281.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2021, Raspberry Pi (Trading) Limited + * Copyright (C) 2021, Raspberry Pi Ltd * * cam_helper_ov9281.cpp - camera information for ov9281 sensor */ diff --git a/src/ipa/raspberrypi/controller/agc_algorithm.h b/src/ipa/raspberrypi/controller/agc_algorithm.h index 610cf7d8454d..3a91444c3a61 100644 --- a/src/ipa/raspberrypi/controller/agc_algorithm.h +++ b/src/ipa/raspberrypi/controller/agc_algorithm.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * agc_algorithm.h - AGC/AEC control algorithm interface */ diff --git a/src/ipa/raspberrypi/controller/agc_status.h b/src/ipa/raspberrypi/controller/agc_status.h index c7b7c1b2d938..6abf09d9df57 100644 --- a/src/ipa/raspberrypi/controller/agc_status.h +++ b/src/ipa/raspberrypi/controller/agc_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * agc_status.h - AGC/AEC control algorithm status */ diff --git a/src/ipa/raspberrypi/controller/algorithm.cpp b/src/ipa/raspberrypi/controller/algorithm.cpp index a28a02adeb0d..1a7d20a4731b 100644 --- a/src/ipa/raspberrypi/controller/algorithm.cpp +++ b/src/ipa/raspberrypi/controller/algorithm.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * algorithm.cpp - ISP control algorithms */ diff --git a/src/ipa/raspberrypi/controller/algorithm.h b/src/ipa/raspberrypi/controller/algorithm.h index ce3ca95f65f6..92fd895d2b06 100644 --- a/src/ipa/raspberrypi/controller/algorithm.h +++ b/src/ipa/raspberrypi/controller/algorithm.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * algorithm.h - ISP control algorithm interface */ diff --git a/src/ipa/raspberrypi/controller/alsc_status.h b/src/ipa/raspberrypi/controller/alsc_status.h index d7122f5190ce..498880daf2d1 100644 --- a/src/ipa/raspberrypi/controller/alsc_status.h +++ b/src/ipa/raspberrypi/controller/alsc_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * alsc_status.h - ALSC (auto lens shading correction) control algorithm status */ diff --git a/src/ipa/raspberrypi/controller/awb_algorithm.h b/src/ipa/raspberrypi/controller/awb_algorithm.h index 712c1aa173bd..48e08b60e221 100644 --- a/src/ipa/raspberrypi/controller/awb_algorithm.h +++ b/src/ipa/raspberrypi/controller/awb_algorithm.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * awb_algorithm.h - AWB control algorithm interface */ diff --git a/src/ipa/raspberrypi/controller/awb_status.h b/src/ipa/raspberrypi/controller/awb_status.h index 353906f8aefd..dd5a79e38b53 100644 --- a/src/ipa/raspberrypi/controller/awb_status.h +++ b/src/ipa/raspberrypi/controller/awb_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * awb_status.h - AWB control algorithm status */ diff --git a/src/ipa/raspberrypi/controller/black_level_status.h b/src/ipa/raspberrypi/controller/black_level_status.h index 8d2c497aef3a..fd5e4ccb2c41 100644 --- a/src/ipa/raspberrypi/controller/black_level_status.h +++ b/src/ipa/raspberrypi/controller/black_level_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * black_level_status.h - black level control algorithm status */ diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h index 6e1597d23a28..0ac6c07fb7bf 100644 --- a/src/ipa/raspberrypi/controller/camera_mode.h +++ b/src/ipa/raspberrypi/controller/camera_mode.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019-2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2019-2020, Raspberry Pi Ltd * * camera_mode.h - description of a particular operating mode of a sensor */ diff --git a/src/ipa/raspberrypi/controller/ccm_algorithm.h b/src/ipa/raspberrypi/controller/ccm_algorithm.h index 324eae14e17a..e2c4d771e0bf 100644 --- a/src/ipa/raspberrypi/controller/ccm_algorithm.h +++ b/src/ipa/raspberrypi/controller/ccm_algorithm.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * ccm_algorithm.h - CCM (colour correction matrix) control algorithm interface */ diff --git a/src/ipa/raspberrypi/controller/ccm_status.h b/src/ipa/raspberrypi/controller/ccm_status.h index 44471d0ef901..5e28ee7c631f 100644 --- a/src/ipa/raspberrypi/controller/ccm_status.h +++ b/src/ipa/raspberrypi/controller/ccm_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * ccm_status.h - CCM (colour correction matrix) control algorithm status */ diff --git a/src/ipa/raspberrypi/controller/contrast_algorithm.h b/src/ipa/raspberrypi/controller/contrast_algorithm.h index eaba62150730..ce17a4f949b9 100644 --- a/src/ipa/raspberrypi/controller/contrast_algorithm.h +++ b/src/ipa/raspberrypi/controller/contrast_algorithm.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * contrast_algorithm.h - contrast (gamma) control algorithm interface */ diff --git a/src/ipa/raspberrypi/controller/contrast_status.h b/src/ipa/raspberrypi/controller/contrast_status.h index 88152575288f..11d55295963b 100644 --- a/src/ipa/raspberrypi/controller/contrast_status.h +++ b/src/ipa/raspberrypi/controller/contrast_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * contrast_status.h - contrast (gamma) control algorithm status */ diff --git a/src/ipa/raspberrypi/controller/controller.cpp b/src/ipa/raspberrypi/controller/controller.cpp index 46229d683a3b..872a32302410 100644 --- a/src/ipa/raspberrypi/controller/controller.cpp +++ b/src/ipa/raspberrypi/controller/controller.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * controller.cpp - ISP controller */ diff --git a/src/ipa/raspberrypi/controller/controller.h b/src/ipa/raspberrypi/controller/controller.h index be8ae8f96288..e28e30d7d574 100644 --- a/src/ipa/raspberrypi/controller/controller.h +++ b/src/ipa/raspberrypi/controller/controller.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * controller.h - ISP controller interface */ diff --git a/src/ipa/raspberrypi/controller/denoise_algorithm.h b/src/ipa/raspberrypi/controller/denoise_algorithm.h index 15a45a417b0c..52009ba95661 100644 --- a/src/ipa/raspberrypi/controller/denoise_algorithm.h +++ b/src/ipa/raspberrypi/controller/denoise_algorithm.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2021, Raspberry Pi (Trading) Limited + * Copyright (C) 2021, Raspberry Pi Ltd * * denoise.h - Denoise control algorithm interface */ diff --git a/src/ipa/raspberrypi/controller/denoise_status.h b/src/ipa/raspberrypi/controller/denoise_status.h index e97368aaab54..f6b9ee29dad6 100644 --- a/src/ipa/raspberrypi/controller/denoise_status.h +++ b/src/ipa/raspberrypi/controller/denoise_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited + * Copyright (C) 2019-2021, Raspberry Pi Ltd * * denoise_status.h - Denoise control algorithm status */ diff --git a/src/ipa/raspberrypi/controller/device_status.cpp b/src/ipa/raspberrypi/controller/device_status.cpp index f8ed77354a0a..2360a77bf1ea 100644 --- a/src/ipa/raspberrypi/controller/device_status.cpp +++ b/src/ipa/raspberrypi/controller/device_status.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2021, Raspberry Pi (Trading) Limited + * Copyright (C) 2021, Raspberry Pi Ltd * * device_status.cpp - device (image sensor) status */ diff --git a/src/ipa/raspberrypi/controller/device_status.h b/src/ipa/raspberrypi/controller/device_status.h index ebcd7da2586b..8f74e21b0c6e 100644 --- a/src/ipa/raspberrypi/controller/device_status.h +++ b/src/ipa/raspberrypi/controller/device_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited + * Copyright (C) 2019-2021, Raspberry Pi Ltd * * device_status.h - device (image sensor) status */ diff --git a/src/ipa/raspberrypi/controller/dpc_status.h b/src/ipa/raspberrypi/controller/dpc_status.h index 685ffc7b91b5..46d0cf34b47f 100644 --- a/src/ipa/raspberrypi/controller/dpc_status.h +++ b/src/ipa/raspberrypi/controller/dpc_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * dpc_status.h - DPC (defective pixel correction) control algorithm status */ diff --git a/src/ipa/raspberrypi/controller/focus_status.h b/src/ipa/raspberrypi/controller/focus_status.h index f0dbe4e2c4a2..8b74e59840c1 100644 --- a/src/ipa/raspberrypi/controller/focus_status.h +++ b/src/ipa/raspberrypi/controller/focus_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2020, Raspberry Pi Ltd * * focus_status.h - focus measurement status */ diff --git a/src/ipa/raspberrypi/controller/geq_status.h b/src/ipa/raspberrypi/controller/geq_status.h index 791f34ca2e52..2d749fc9085c 100644 --- a/src/ipa/raspberrypi/controller/geq_status.h +++ b/src/ipa/raspberrypi/controller/geq_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * geq_status.h - GEQ (green equalisation) control algorithm status */ diff --git a/src/ipa/raspberrypi/controller/histogram.cpp b/src/ipa/raspberrypi/controller/histogram.cpp index f0c4adaf1f44..16a9207ff2f8 100644 --- a/src/ipa/raspberrypi/controller/histogram.cpp +++ b/src/ipa/raspberrypi/controller/histogram.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * histogram.cpp - histogram calculations */ diff --git a/src/ipa/raspberrypi/controller/histogram.h b/src/ipa/raspberrypi/controller/histogram.h index 33ba76c1f081..66a68b087964 100644 --- a/src/ipa/raspberrypi/controller/histogram.h +++ b/src/ipa/raspberrypi/controller/histogram.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * histogram.h - histogram calculation interface */ diff --git a/src/ipa/raspberrypi/controller/lux_status.h b/src/ipa/raspberrypi/controller/lux_status.h index cd5ed473c10d..5eb9faac8b08 100644 --- a/src/ipa/raspberrypi/controller/lux_status.h +++ b/src/ipa/raspberrypi/controller/lux_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * lux_status.h - Lux control algorithm status */ diff --git a/src/ipa/raspberrypi/controller/metadata.h b/src/ipa/raspberrypi/controller/metadata.h index e46d0f9fabbf..0f7ebfaf4c25 100644 --- a/src/ipa/raspberrypi/controller/metadata.h +++ b/src/ipa/raspberrypi/controller/metadata.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited + * Copyright (C) 2019-2021, Raspberry Pi Ltd * * metadata.h - general metadata class */ diff --git a/src/ipa/raspberrypi/controller/noise_status.h b/src/ipa/raspberrypi/controller/noise_status.h index 843260f013ae..da194f71b8e3 100644 --- a/src/ipa/raspberrypi/controller/noise_status.h +++ b/src/ipa/raspberrypi/controller/noise_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * noise_status.h - Noise control algorithm status */ diff --git a/src/ipa/raspberrypi/controller/pwl.cpp b/src/ipa/raspberrypi/controller/pwl.cpp index b02979f060f0..8b8db722966b 100644 --- a/src/ipa/raspberrypi/controller/pwl.cpp +++ b/src/ipa/raspberrypi/controller/pwl.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * pwl.cpp - piecewise linear functions */ diff --git a/src/ipa/raspberrypi/controller/pwl.h b/src/ipa/raspberrypi/controller/pwl.h index 128990c5ca6c..973efdf59945 100644 --- a/src/ipa/raspberrypi/controller/pwl.h +++ b/src/ipa/raspberrypi/controller/pwl.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * pwl.h - piecewise linear functions interface */ diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index 0c66e1c4758c..000ab03e2ff7 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * agc.cpp - AGC/AEC control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/agc.h b/src/ipa/raspberrypi/controller/rpi/agc.h index d6b19d6f4112..48b33a10c73a 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.h +++ b/src/ipa/raspberrypi/controller/rpi/agc.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * agc.h - AGC/AEC control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp index 709e069d689f..35da336ebc72 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * alsc.cpp - ALSC (auto lens shading correction) control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.h b/src/ipa/raspberrypi/controller/rpi/alsc.h index 1ee88a663d31..e17f2fe93379 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.h +++ b/src/ipa/raspberrypi/controller/rpi/alsc.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * alsc.h - ALSC (auto lens shading correction) control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index eea255b2b14e..a20a09e987af 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * awb.cpp - AWB control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/awb.h b/src/ipa/raspberrypi/controller/rpi/awb.h index 2f7a88acebcb..9e075624c429 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.h +++ b/src/ipa/raspberrypi/controller/rpi/awb.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * awb.h - AWB control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.cpp b/src/ipa/raspberrypi/controller/rpi/black_level.cpp index 5bc6a4986256..0799d7b9195a 100644 --- a/src/ipa/raspberrypi/controller/rpi/black_level.cpp +++ b/src/ipa/raspberrypi/controller/rpi/black_level.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * black_level.cpp - black level control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/black_level.h b/src/ipa/raspberrypi/controller/rpi/black_level.h index ecb83e35dfdd..7789f261cf03 100644 --- a/src/ipa/raspberrypi/controller/rpi/black_level.h +++ b/src/ipa/raspberrypi/controller/rpi/black_level.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * black_level.h - black level control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.cpp b/src/ipa/raspberrypi/controller/rpi/ccm.cpp index a81358d5b6d2..8095c42dc0c8 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.cpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * ccm.cpp - CCM (colour correction matrix) control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.h b/src/ipa/raspberrypi/controller/rpi/ccm.h index 57c3518e7490..b44f1576528f 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.h +++ b/src/ipa/raspberrypi/controller/rpi/ccm.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * ccm.h - CCM (colour correction matrix) control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.cpp b/src/ipa/raspberrypi/controller/rpi/contrast.cpp index 3e0177345119..04aeb91e4d61 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.cpp +++ b/src/ipa/raspberrypi/controller/rpi/contrast.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * contrast.cpp - contrast (gamma) control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.h b/src/ipa/raspberrypi/controller/rpi/contrast.h index 4568e087008f..b1375d819dbc 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.h +++ b/src/ipa/raspberrypi/controller/rpi/contrast.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * contrast.h - contrast (gamma) control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.cpp b/src/ipa/raspberrypi/controller/rpi/dpc.cpp index af3c88d7ac3a..9cd78abe28d6 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/dpc.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * dpc.cpp - DPC (defective pixel correction) control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.h b/src/ipa/raspberrypi/controller/rpi/dpc.h index d3fce5e37dd2..4c1bdec6dd87 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.h +++ b/src/ipa/raspberrypi/controller/rpi/dpc.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * dpc.h - DPC (defective pixel correction) control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/focus.cpp b/src/ipa/raspberrypi/controller/rpi/focus.cpp index 22f376b74fbf..8c5029bd0e95 100644 --- a/src/ipa/raspberrypi/controller/rpi/focus.cpp +++ b/src/ipa/raspberrypi/controller/rpi/focus.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2020, Raspberry Pi Ltd * * focus.cpp - focus algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/focus.h b/src/ipa/raspberrypi/controller/rpi/focus.h index 3b71d686bfb8..8556039d9813 100644 --- a/src/ipa/raspberrypi/controller/rpi/focus.h +++ b/src/ipa/raspberrypi/controller/rpi/focus.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2020, Raspberry Pi Ltd * * focus.h - focus algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/geq.cpp b/src/ipa/raspberrypi/controller/rpi/geq.cpp index 1a94c45e16fa..4e8ed696851b 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.cpp +++ b/src/ipa/raspberrypi/controller/rpi/geq.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * geq.cpp - GEQ (green equalisation) control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/geq.h b/src/ipa/raspberrypi/controller/rpi/geq.h index 54f72cce0721..5d06b9cbd529 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.h +++ b/src/ipa/raspberrypi/controller/rpi/geq.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * geq.h - GEQ (green equalisation) control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/lux.cpp b/src/ipa/raspberrypi/controller/rpi/lux.cpp index 218ded7dc5fd..95c0a93b2810 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.cpp +++ b/src/ipa/raspberrypi/controller/rpi/lux.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * lux.cpp - Lux control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/lux.h b/src/ipa/raspberrypi/controller/rpi/lux.h index 530470c22ce5..26af8185911c 100644 --- a/src/ipa/raspberrypi/controller/rpi/lux.h +++ b/src/ipa/raspberrypi/controller/rpi/lux.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * lux.h - Lux control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/noise.cpp b/src/ipa/raspberrypi/controller/rpi/noise.cpp index aaaafe6b8699..5d2c85ad3e74 100644 --- a/src/ipa/raspberrypi/controller/rpi/noise.cpp +++ b/src/ipa/raspberrypi/controller/rpi/noise.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * noise.cpp - Noise control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/noise.h b/src/ipa/raspberrypi/controller/rpi/noise.h index cf56fafef405..144e36529f4c 100644 --- a/src/ipa/raspberrypi/controller/rpi/noise.h +++ b/src/ipa/raspberrypi/controller/rpi/noise.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * noise.h - Noise control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.cpp b/src/ipa/raspberrypi/controller/rpi/sdn.cpp index 4fe1da33d46b..af31bd0881f0 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sdn.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited + * Copyright (C) 2019-2021, Raspberry Pi Ltd * * sdn.cpp - SDN (spatial denoise) control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/sdn.h b/src/ipa/raspberrypi/controller/rpi/sdn.h index 72d9d3fff917..90ea37ff5550 100644 --- a/src/ipa/raspberrypi/controller/rpi/sdn.h +++ b/src/ipa/raspberrypi/controller/rpi/sdn.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * sdn.h - SDN (spatial denoise) control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp index 71c8e529cd25..36b75f69afce 100644 --- a/src/ipa/raspberrypi/controller/rpi/sharpen.cpp +++ b/src/ipa/raspberrypi/controller/rpi/sharpen.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * sharpen.cpp - sharpening control algorithm */ diff --git a/src/ipa/raspberrypi/controller/rpi/sharpen.h b/src/ipa/raspberrypi/controller/rpi/sharpen.h index 643fb94e8b9a..8846f2ae09a2 100644 --- a/src/ipa/raspberrypi/controller/rpi/sharpen.h +++ b/src/ipa/raspberrypi/controller/rpi/sharpen.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * sharpen.h - sharpening control algorithm */ diff --git a/src/ipa/raspberrypi/controller/sharpen_algorithm.h b/src/ipa/raspberrypi/controller/sharpen_algorithm.h index 3f585f64edcb..3be21c32f7bc 100644 --- a/src/ipa/raspberrypi/controller/sharpen_algorithm.h +++ b/src/ipa/raspberrypi/controller/sharpen_algorithm.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2020, Raspberry Pi Ltd * * sharpen_algorithm.h - sharpness control algorithm interface */ diff --git a/src/ipa/raspberrypi/controller/sharpen_status.h b/src/ipa/raspberrypi/controller/sharpen_status.h index c66eaa73af3b..106166db8319 100644 --- a/src/ipa/raspberrypi/controller/sharpen_status.h +++ b/src/ipa/raspberrypi/controller/sharpen_status.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * sharpen_status.h - Sharpen control algorithm status */ diff --git a/src/ipa/raspberrypi/md_parser.h b/src/ipa/raspberrypi/md_parser.h index 1cb461cb3db7..77d557aa3c9b 100644 --- a/src/ipa/raspberrypi/md_parser.h +++ b/src/ipa/raspberrypi/md_parser.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019, Raspberry Pi (Trading) Limited + * Copyright (C) 2019, Raspberry Pi Ltd * * md_parser.h - image sensor metadata parser interface */ diff --git a/src/ipa/raspberrypi/md_parser_smia.cpp b/src/ipa/raspberrypi/md_parser_smia.cpp index 4ea4bc3dd400..1ec1519f719f 100644 --- a/src/ipa/raspberrypi/md_parser_smia.cpp +++ b/src/ipa/raspberrypi/md_parser_smia.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019-2021, Raspberry Pi (Trading) Limited + * Copyright (C) 2019-2021, Raspberry Pi Ltd * * md_parser_smia.cpp - SMIA specification based embedded data parser */ diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 282257171e15..951d8c65abfd 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-2-Clause */ /* - * Copyright (C) 2019-2021, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2019-2021, Raspberry Pi Ltd * * rpi.cpp - Raspberry Pi Image Processing Algorithms */ diff --git a/src/libcamera/bayer_format.cpp b/src/libcamera/bayer_format.cpp index 4882707e7763..c2a52f4740d6 100644 --- a/src/libcamera/bayer_format.cpp +++ b/src/libcamera/bayer_format.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2020, Raspberry Pi Ltd * * bayer_format.cpp - Class to represent Bayer formats */ diff --git a/src/libcamera/color_space.cpp b/src/libcamera/color_space.cpp index 895e5c8e667d..caf397607b10 100644 --- a/src/libcamera/color_space.cpp +++ b/src/libcamera/color_space.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2021, Raspberry Pi (Trading) Limited + * Copyright (C) 2021, Raspberry Pi Ltd * * color_space.cpp - color spaces. */ diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp index 527c319113ac..777441e8222a 100644 --- a/src/libcamera/delayed_controls.cpp +++ b/src/libcamera/delayed_controls.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2020, Raspberry Pi Ltd * * delayed_controls.h - Helper to deal with controls that take effect with a delay */ diff --git a/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp b/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp index 69831dabbe75..6b644406c90f 100644 --- a/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp +++ b/src/libcamera/pipeline/raspberrypi/dma_heaps.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2020, Raspberry Pi Ltd * * dma_heaps.h - Helper class for dma-heap allocations. */ diff --git a/src/libcamera/pipeline/raspberrypi/dma_heaps.h b/src/libcamera/pipeline/raspberrypi/dma_heaps.h index d38f41eae1a2..0a4a8d86f8ca 100644 --- a/src/libcamera/pipeline/raspberrypi/dma_heaps.h +++ b/src/libcamera/pipeline/raspberrypi/dma_heaps.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2020, Raspberry Pi Ltd * * dma_heaps.h - Helper class for dma-heap allocations. */ diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index c130260fd292..d4ce4289d5f7 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2019-2021, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2019-2021, Raspberry Pi Ltd * * raspberrypi.cpp - Pipeline handler for Raspberry Pi devices */ diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp index 7a93efaa29da..79f7be130ed4 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2020, Raspberry Pi Ltd * * rpi_stream.cpp - Raspberry Pi device stream abstraction class. */ diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.h b/src/libcamera/pipeline/raspberrypi/rpi_stream.h index fe01110019b7..3c0b5c8ebab4 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.h +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2020, Raspberry Pi Ltd * * rpi_stream.h - Raspberry Pi device stream abstraction class. */ diff --git a/src/libcamera/transform.cpp b/src/libcamera/transform.cpp index 99a043ba14d3..4668303d0676 100644 --- a/src/libcamera/transform.cpp +++ b/src/libcamera/transform.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Limited + * Copyright (C) 2020, Raspberry Pi Ltd * * transform.cpp - 2D plane transforms. */ diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp index 58fc4e9d2032..bdcdc3be4e0c 100644 --- a/src/libcamera/v4l2_pixelformat.cpp +++ b/src/libcamera/v4l2_pixelformat.cpp @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright (C) 2019, Google Inc. - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2020, Raspberry Pi Ltd * * v4l2_pixelformat.cpp - V4L2 Pixel Format */ diff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp index 5896485cda5b..5b94b3f25688 100644 --- a/src/qcam/dng_writer.cpp +++ b/src/qcam/dng_writer.cpp @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2020, Raspberry Pi Ltd * * dng_writer.cpp - DNG writer */ diff --git a/src/qcam/dng_writer.h b/src/qcam/dng_writer.h index c044bf8b8162..38f38f62d4b9 100644 --- a/src/qcam/dng_writer.h +++ b/src/qcam/dng_writer.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ /* - * Copyright (C) 2020, Raspberry Pi (Trading) Ltd. + * Copyright (C) 2020, Raspberry Pi Ltd * * dng_writer.h - DNG writer */ diff --git a/utils/raspberrypi/ctt/ctt.py b/utils/raspberrypi/ctt/ctt.py index 15064634c67f..13765b5d52f6 100755 --- a/utils/raspberrypi/ctt/ctt.py +++ b/utils/raspberrypi/ctt/ctt.py @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (C) 2019, Raspberry Pi (Trading) Limited +# Copyright (C) 2019, Raspberry Pi Ltd # # ctt.py - camera tuning tool diff --git a/utils/raspberrypi/ctt/ctt_alsc.py b/utils/raspberrypi/ctt/ctt_alsc.py index 89e86469a78e..c0ba7b6371fc 100644 --- a/utils/raspberrypi/ctt/ctt_alsc.py +++ b/utils/raspberrypi/ctt/ctt_alsc.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (C) 2019, Raspberry Pi (Trading) Limited +# Copyright (C) 2019, Raspberry Pi Ltd # # ctt_alsc.py - camera tuning tool for ALSC (auto lens shading correction) diff --git a/utils/raspberrypi/ctt/ctt_awb.py b/utils/raspberrypi/ctt/ctt_awb.py index 3c8cd9027a1a..bf45e54d5910 100644 --- a/utils/raspberrypi/ctt/ctt_awb.py +++ b/utils/raspberrypi/ctt/ctt_awb.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (C) 2019, Raspberry Pi (Trading) Limited +# Copyright (C) 2019, Raspberry Pi Ltd # # ctt_awb.py - camera tuning tool for AWB diff --git a/utils/raspberrypi/ctt/ctt_ccm.py b/utils/raspberrypi/ctt/ctt_ccm.py index cebecfc248a6..376cc7125eb1 100644 --- a/utils/raspberrypi/ctt/ctt_ccm.py +++ b/utils/raspberrypi/ctt/ctt_ccm.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (C) 2019, Raspberry Pi (Trading) Limited +# Copyright (C) 2019, Raspberry Pi Ltd # # ctt_ccm.py - camera tuning tool for CCM (colour correction matrix) diff --git a/utils/raspberrypi/ctt/ctt_geq.py b/utils/raspberrypi/ctt/ctt_geq.py index 2aa668f133a8..c45addcdcfe1 100644 --- a/utils/raspberrypi/ctt/ctt_geq.py +++ b/utils/raspberrypi/ctt/ctt_geq.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (C) 2019, Raspberry Pi (Trading) Limited +# Copyright (C) 2019, Raspberry Pi Ltd # # ctt_geq.py - camera tuning tool for GEQ (green equalisation) diff --git a/utils/raspberrypi/ctt/ctt_image_load.py b/utils/raspberrypi/ctt/ctt_image_load.py index 934db1232f7b..c3d444cdd034 100644 --- a/utils/raspberrypi/ctt/ctt_image_load.py +++ b/utils/raspberrypi/ctt/ctt_image_load.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (C) 2019-2020, Raspberry Pi (Trading) Limited +# Copyright (C) 2019-2020, Raspberry Pi Ltd # # ctt_image_load.py - camera tuning tool image loading diff --git a/utils/raspberrypi/ctt/ctt_lux.py b/utils/raspberrypi/ctt/ctt_lux.py index 4e7785ef35e1..70855e1b75f3 100644 --- a/utils/raspberrypi/ctt/ctt_lux.py +++ b/utils/raspberrypi/ctt/ctt_lux.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (C) 2019, Raspberry Pi (Trading) Limited +# Copyright (C) 2019, Raspberry Pi Ltd # # ctt_lux.py - camera tuning tool for lux level diff --git a/utils/raspberrypi/ctt/ctt_macbeth_locator.py b/utils/raspberrypi/ctt/ctt_macbeth_locator.py index cae1d334cc19..3e95df89e008 100644 --- a/utils/raspberrypi/ctt/ctt_macbeth_locator.py +++ b/utils/raspberrypi/ctt/ctt_macbeth_locator.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (C) 2019, Raspberry Pi (Trading) Limited +# Copyright (C) 2019, Raspberry Pi Ltd # # ctt_macbeth_locator.py - camera tuning tool Macbeth chart locator diff --git a/utils/raspberrypi/ctt/ctt_noise.py b/utils/raspberrypi/ctt/ctt_noise.py index 0afcf8f850cc..3270bf341c87 100644 --- a/utils/raspberrypi/ctt/ctt_noise.py +++ b/utils/raspberrypi/ctt/ctt_noise.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (C) 2019, Raspberry Pi (Trading) Limited +# Copyright (C) 2019, Raspberry Pi Ltd # # ctt_noise.py - camera tuning tool noise calibration diff --git a/utils/raspberrypi/ctt/ctt_pretty_print_json.py b/utils/raspberrypi/ctt/ctt_pretty_print_json.py index d38ae6178524..0176aec63028 100644 --- a/utils/raspberrypi/ctt/ctt_pretty_print_json.py +++ b/utils/raspberrypi/ctt/ctt_pretty_print_json.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (C) 2019, Raspberry Pi (Trading) Limited +# Copyright (C) 2019, Raspberry Pi Ltd # # ctt_pretty_print_json.py - camera tuning tool JSON formatter diff --git a/utils/raspberrypi/ctt/ctt_ransac.py b/utils/raspberrypi/ctt/ctt_ransac.py index 11515a4fab08..9ed7d93c511f 100644 --- a/utils/raspberrypi/ctt/ctt_ransac.py +++ b/utils/raspberrypi/ctt/ctt_ransac.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (C) 2019, Raspberry Pi (Trading) Limited +# Copyright (C) 2019, Raspberry Pi Ltd # # ctt_ransac.py - camera tuning tool RANSAC selector for Macbeth chart locator diff --git a/utils/raspberrypi/ctt/ctt_tools.py b/utils/raspberrypi/ctt/ctt_tools.py index 8728ff1627aa..79195289b6fc 100644 --- a/utils/raspberrypi/ctt/ctt_tools.py +++ b/utils/raspberrypi/ctt/ctt_tools.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# Copyright (C) 2019, Raspberry Pi (Trading) Limited +# Copyright (C) 2019, Raspberry Pi Ltd # # ctt_tools.py - camera tuning tool miscellaneous From patchwork Tue Jul 26 12:45:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16788 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 0E094C3275 for ; Tue, 26 Jul 2022 12:46:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AE86663328; Tue, 26 Jul 2022 14:46:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839578; bh=IvE0AUztvqKidMRgwxhQcrPEL0XYqVbeJBUIM7fqEII=; 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=RUMksnQ9ukO1pT2WJRmrtIGPCuS6ljSTbw6rMJzi7h0suFo7UESw+48MXQfTNArMb I9ks7lMOp25KrLXVlnY6dSWI3A6spH+5TbMGuEFVKnf6U8dtpmHQPpqFFqy/OPcA8o xGxBVh9l3SYWIWvIlUmLFS66OW6wTXEz37jtCGUdPZfoKz8E6sHQ+nUlx74US5XsNr EZqFfadqg3dbCbA+YJn0N4XnXhtG+orkXoHxnBYt9xMp3OZirHGq0ZcwFWgl7Tuu0f mv7hU86SaXoFMjf/B3HB/AE/nVKPq5NQ8quSYIO1l5lc0iCQJGh2KrHFBMBcNjz7wP L6SGyCVnEqhag== Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 81E0A63329 for ; Tue, 26 Jul 2022 14:46:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="UY/TetYc"; dkim-atps=neutral Received: by mail-wr1-x436.google.com with SMTP id u5so19995458wrm.4 for ; Tue, 26 Jul 2022 05:46:12 -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=l5fV6kN4UH7/CrZllIjvQWPAyZOX1oO6ts232+aaqGA=; b=UY/TetYcyuYO8S/DAbGIdmBh+A8rLgG0OCTaaMUvduQz6YmFx2q1hrpcSHb08TuT5B BA2lt0jLKQE8/YH6Oo1LnVyP5/5ObXuEan6JfvkVtysdkP67q1AkFFSRYJGRyQqWaCYf heoNROg2RSDXXGcAKCfVdEZsFBemIN9WHFo9iXN1GuJAvu9AuAcyPYMvwiYfChBPeEKZ /x4PiNF/Z/NNsbLJJcJho8ihN8+TX3spmzRDxQ6iFefTiF8Svlw9M1Ywma8XBSxz1+f/ xYUTPXoeTIOzu22pTDvtCazD7Ha0dDHGv9s4OlwgLBvxXuBlxPd22HvvwdRLaohn/mbg dktg== 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=l5fV6kN4UH7/CrZllIjvQWPAyZOX1oO6ts232+aaqGA=; b=URI+au1pShoCKWapu99y/h/vAYMm4CvEAaeDGTW3+TFA/h1W1h7kuAzhkx6AgAqMS/ THCsx5ygg/HzrVjyqN0pedRwmWpH9H/gjlIoiucuCFKDJY3vx/EWOWP7wLm5FkIOwoDw rji5YyxcMyRBOmQ75XUPSnug6q/xYR4+aTuAPjHSPqSNkxone+Tc5YgDoJZkj7oNVKx6 vEizWoES24z3oNtXBS+47kXNGt9fBvwo23ge1UZQKacpjjhZ4N5zXgnHQxyK1mD433o9 0HNIjEXheiOegPlJrTofDhuldBRuVK2uYtIy5kHAdNGMFoofTIeCmCbl2pbe70FKg9PD FjSg== X-Gm-Message-State: AJIora+tqoex+50y9HsSwgr47NnhrMms+z95o4lBh6wW9w7YT8ydUk+g r2YKRdPEw+JpnQ7NY3AuP4fRZwM0mr2zVA== X-Google-Smtp-Source: AGRyM1tFGBsilgArYnBFUvf8wAPQOliz761paG9co5Y06S/z+xyitpdWadr/tJJYzZ3A2YE3ayIstQ== X-Received: by 2002:adf:f452:0:b0:21e:86ac:cd74 with SMTP id f18-20020adff452000000b0021e86accd74mr7180742wrp.194.1658839571503; Tue, 26 Jul 2022 05:46:11 -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.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:46:10 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:47 +0100 Message-Id: <20220726124549.1646-16-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 15/17] ipa: raspberryip: Remove all exception throw statements 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" Replace all exception throw statements with LOG(RPi*, Fatal) error messages. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/rpi/agc.cpp | 26 +++++++++------------ src/ipa/raspberrypi/controller/rpi/alsc.cpp | 25 ++++++++------------ src/ipa/raspberrypi/controller/rpi/awb.cpp | 18 ++++++-------- src/ipa/raspberrypi/controller/rpi/ccm.cpp | 9 ++++--- src/ipa/raspberrypi/controller/rpi/dpc.cpp | 2 +- src/ipa/raspberrypi/controller/rpi/geq.cpp | 2 +- 6 files changed, 34 insertions(+), 48 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index 000ab03e2ff7..e9a945e3a630 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -35,11 +35,11 @@ void AgcMeteringMode::read(boost::property_tree::ptree const ¶ms) int num = 0; for (auto &p : params.get_child("weights")) { if (num == AGC_STATS_SIZE) - throw std::runtime_error("AgcConfig: too many weights"); + LOG(RPiAgc, Fatal) << "AgcConfig: too many weights"; weights[num++] = p.second.get_value(); } if (num != AGC_STATS_SIZE) - throw std::runtime_error("AgcConfig: insufficient weights"); + LOG(RPiAgc, Fatal) << "AgcConfig: insufficient weights"; } static std::string @@ -78,11 +78,11 @@ void AgcExposureMode::read(boost::property_tree::ptree const ¶ms) int numShutters = readList(shutter, params.get_child("shutter")); int numAgs = readList(gain, params.get_child("gain")); if (numShutters < 2 || numAgs < 2) - throw std::runtime_error( - "AgcConfig: must have at least two entries in exposure profile"); + LOG(RPiAgc, Fatal) + << "AgcConfig: must have at least two entries in exposure profile"; if (numShutters != numAgs) - throw std::runtime_error( - "AgcConfig: expect same number of exposure and gain entries in exposure profile"); + LOG(RPiAgc, Fatal) + << "AgcConfig: expect same number of exposure and gain entries in exposure profile"; } static std::string @@ -106,8 +106,7 @@ void AgcConstraint::read(boost::property_tree::ptree const ¶ms) transform(boundString.begin(), boundString.end(), boundString.begin(), ::toupper); if (boundString != "UPPER" && boundString != "LOWER") - throw std::runtime_error( - "AGC constraint type should be UPPER or LOWER"); + LOG(RPiAgc, Fatal) << "AGC constraint type should be UPPER or LOWER"; bound = boundString == "UPPER" ? Bound::UPPER : Bound::LOWER; qLo = params.get("q_lo"); qHi = params.get("q_hi"); @@ -465,8 +464,7 @@ void Agc::housekeepConfig() if (strcmp(meteringModeName_.c_str(), status_.meteringMode)) { auto it = config_.meteringModes.find(meteringModeName_); if (it == config_.meteringModes.end()) - throw std::runtime_error("Agc: no metering mode " + - meteringModeName_); + LOG(RPiAgc, Fatal) << "Agc: no metering mode " << meteringModeName_; meteringMode_ = &it->second; copyString(meteringModeName_, status_.meteringMode, sizeof(status_.meteringMode)); @@ -474,8 +472,7 @@ void Agc::housekeepConfig() if (strcmp(exposureModeName_.c_str(), status_.exposureMode)) { auto it = config_.exposureModes.find(exposureModeName_); if (it == config_.exposureModes.end()) - throw std::runtime_error("Agc: no exposure profile " + - exposureModeName_); + LOG(RPiAgc, Fatal) << "Agc: no exposure profile " << exposureModeName_; exposureMode_ = &it->second; copyString(exposureModeName_, status_.exposureMode, sizeof(status_.exposureMode)); @@ -484,8 +481,7 @@ void Agc::housekeepConfig() auto it = config_.constraintModes.find(constraintModeName_); if (it == config_.constraintModes.end()) - throw std::runtime_error("Agc: no constraint list " + - constraintModeName_); + LOG(RPiAgc, Fatal) << "Agc: no constraint list " << constraintModeName_; constraintMode_ = &it->second; copyString(constraintModeName_, status_.constraintMode, sizeof(status_.constraintMode)); @@ -502,7 +498,7 @@ void Agc::fetchCurrentExposure(Metadata *imageMetadata) DeviceStatus *deviceStatus = imageMetadata->getLocked("device.status"); if (!deviceStatus) - throw std::runtime_error("Agc: no device metadata"); + LOG(RPiAgc, Fatal) << "Agc: no device metadata"; current_.shutter = deviceStatus->shutterSpeed; current_.analogueGain = deviceStatus->analogueGain; AgcStatus *agcStatus = diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp index 35da336ebc72..7df89445711a 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp @@ -54,10 +54,10 @@ static void generateLut(double *lut, boost::property_tree::ptree const ¶ms) { double cstrength = params.get("corner_strength", 2.0); if (cstrength <= 1.0) - throw std::runtime_error("Alsc: corner_strength must be > 1.0"); + LOG(RPiAlsc, Fatal) << "Alsc: corner_strength must be > 1.0"; double asymmetry = params.get("asymmetry", 1.0); if (asymmetry < 0) - throw std::runtime_error("Alsc: asymmetry must be >= 0"); + LOG(RPiAlsc, Fatal) << "Alsc: asymmetry must be >= 0"; double f1 = cstrength - 1, f2 = 1 + sqrt(cstrength); double R2 = X * Y / 4 * (1 + asymmetry * asymmetry); int num = 0; @@ -79,12 +79,11 @@ static void readLut(double *lut, boost::property_tree::ptree const ¶ms) const int maxNum = XY; for (auto &p : params) { if (num == maxNum) - throw std::runtime_error( - "Alsc: too many entries in LSC table"); + LOG(RPiAlsc, Fatal) << "Alsc: too many entries in LSC table"; lut[num++] = p.second.get_value(); } if (num < maxNum) - throw std::runtime_error("Alsc: too few entries in LSC table"); + LOG(RPiAlsc, Fatal) << "Alsc: too few entries in LSC table"; } static void readCalibrations(std::vector &calibrations, @@ -96,9 +95,8 @@ static void readCalibrations(std::vector &calibrations, for (auto &p : params.get_child(name)) { double ct = p.second.get("ct"); if (ct <= lastCt) - throw std::runtime_error( - "Alsc: entries in " + name + - " must be in increasing ct order"); + LOG(RPiAlsc, Fatal) + << "Alsc: entries in " << name << " must be in increasing ct order"; AlscCalibration calibration; calibration.ct = lastCt = ct; boost::property_tree::ptree const &table = @@ -106,17 +104,14 @@ static void readCalibrations(std::vector &calibrations, int num = 0; for (auto it = table.begin(); it != table.end(); it++) { if (num == XY) - throw std::runtime_error( - "Alsc: too many values for ct " + - std::to_string(ct) + " in " + - name); + LOG(RPiAlsc, Fatal) + << "Alsc: too many values for ct " << ct << " in " << name; calibration.table[num++] = it->second.get_value(); } if (num != XY) - throw std::runtime_error( - "Alsc: too few values for ct " + - std::to_string(ct) + " in " + name); + LOG(RPiAlsc, Fatal) + << "Alsc: too few values for ct " << ct << " in " << name; calibrations.push_back(calibration); LOG(RPiAlsc, Debug) << "Read " << name << " calibration for ct " << ct; diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index a20a09e987af..c379e6b92649 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp @@ -46,18 +46,15 @@ static void readCtCurve(Pwl &ctR, Pwl &ctB, double ct = it->second.get_value(); assert(it == params.begin() || ct != ctR.domain().end); if (++it == params.end()) - throw std::runtime_error( - "AwbConfig: incomplete CT curve entry"); + LOG(RPiAwb, Fatal) << "AwbConfig: incomplete CT curve entry"; ctR.append(ct, it->second.get_value()); if (++it == params.end()) - throw std::runtime_error( - "AwbConfig: incomplete CT curve entry"); + LOG(RPiAwb, Fatal) << "AwbConfig: incomplete CT curve entry"; ctB.append(ct, it->second.get_value()); num++; } if (num < 2) - throw std::runtime_error( - "AwbConfig: insufficient points in CT curve"); + LOG(RPiAwb, Fatal) << "AwbConfig: insufficient points in CT curve"; } void AwbConfig::read(boost::property_tree::ptree const ¶ms) @@ -74,12 +71,11 @@ void AwbConfig::read(boost::property_tree::ptree const ¶ms) AwbPrior prior; prior.read(p.second); if (!priors.empty() && prior.lux <= priors.back().lux) - throw std::runtime_error("AwbConfig: Prior must be ordered in increasing lux value"); + LOG(RPiAwb, Fatal) << "AwbConfig: Prior must be ordered in increasing lux value"; priors.push_back(prior); } if (priors.empty()) - throw std::runtime_error( - "AwbConfig: no AWB priors configured"); + LOG(RPiAwb, Fatal) << "AwbConfig: no AWB priors configured"; } if (params.get_child_optional("modes")) { for (auto &p : params.get_child("modes")) { @@ -88,7 +84,7 @@ void AwbConfig::read(boost::property_tree::ptree const ¶ms) defaultMode = &modes[p.first]; } if (defaultMode == nullptr) - throw std::runtime_error("AwbConfig: no AWB modes configured"); + LOG(RPiAwb, Fatal) << "AwbConfig: no AWB modes configured"; } minPixels = params.get("min_pixels", 16.0); minG = params.get("min_G", 32); @@ -98,7 +94,7 @@ void AwbConfig::read(boost::property_tree::ptree const ¶ms) transversePos = params.get("transverse_pos", 0.01); transverseNeg = params.get("transverse_neg", 0.01); if (transversePos <= 0 || transverseNeg <= 0) - throw std::runtime_error("AwbConfig: transverse_pos/neg must be > 0"); + LOG(RPiAwb, Fatal) << "AwbConfig: transverse_pos/neg must be > 0"; sensitivityR = params.get("sensitivity_r", 1.0); sensitivityB = params.get("sensitivity_b", 1.0); if (bayes) { diff --git a/src/ipa/raspberrypi/controller/rpi/ccm.cpp b/src/ipa/raspberrypi/controller/rpi/ccm.cpp index 8095c42dc0c8..cf0c85d26cf9 100644 --- a/src/ipa/raspberrypi/controller/rpi/ccm.cpp +++ b/src/ipa/raspberrypi/controller/rpi/ccm.cpp @@ -45,11 +45,11 @@ void Matrix::read(boost::property_tree::ptree const ¶ms) int n = 0; for (auto it = params.begin(); it != params.end(); it++) { if (n++ == 9) - throw std::runtime_error("Ccm: too many values in CCM"); + LOG(RPiCcm, Fatal) << "Ccm: too many values in CCM"; *ptr++ = it->second.get_value(); } if (n < 9) - throw std::runtime_error("Ccm: too few values in CCM"); + LOG(RPiCcm, Fatal) << "Ccm: too few values in CCM"; } Ccm::Ccm(Controller *controller) @@ -70,12 +70,11 @@ void Ccm::read(boost::property_tree::ptree const ¶ms) ctCcm.ccm.read(p.second.get_child("ccm")); if (!config_.ccms.empty() && ctCcm.ct <= config_.ccms.back().ct) - throw std::runtime_error( - "Ccm: CCM not in increasing colour temperature order"); + LOG(RPiCcm, Fatal) << "Ccm: CCM not in increasing colour temperature order"; config_.ccms.push_back(std::move(ctCcm)); } if (config_.ccms.empty()) - throw std::runtime_error("Ccm: no CCMs specified"); + LOG(RPiCcm, Fatal) << "Ccm: no CCMs specified"; } void Ccm::setSaturation(double saturation) diff --git a/src/ipa/raspberrypi/controller/rpi/dpc.cpp b/src/ipa/raspberrypi/controller/rpi/dpc.cpp index 9cd78abe28d6..d5d784e7ca64 100644 --- a/src/ipa/raspberrypi/controller/rpi/dpc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/dpc.cpp @@ -35,7 +35,7 @@ void Dpc::read(boost::property_tree::ptree const ¶ms) { config_.strength = params.get("strength", 1); if (config_.strength < 0 || config_.strength > 2) - throw std::runtime_error("Dpc: bad strength value"); + LOG(RPiDpc, Fatal) << "Dpc: bad strength value"; } void Dpc::prepare(Metadata *imageMetadata) diff --git a/src/ipa/raspberrypi/controller/rpi/geq.cpp b/src/ipa/raspberrypi/controller/rpi/geq.cpp index 4e8ed696851b..696da4aeea59 100644 --- a/src/ipa/raspberrypi/controller/rpi/geq.cpp +++ b/src/ipa/raspberrypi/controller/rpi/geq.cpp @@ -40,7 +40,7 @@ void Geq::read(boost::property_tree::ptree const ¶ms) config_.offset = params.get("offset", 0); config_.slope = params.get("slope", 0.0); if (config_.slope < 0.0 || config_.slope >= 1.0) - throw std::runtime_error("Geq: bad slope value"); + LOG(RPiGeq, Fatal) << "Geq: bad slope value"; if (params.get_child_optional("strength")) config_.strength.read(params.get_child("strength")); } From patchwork Tue Jul 26 12:45:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16789 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 CA211C3275 for ; Tue, 26 Jul 2022 12:46:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 83FF46333F; Tue, 26 Jul 2022 14:46:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839579; bh=e6FvbeLkjaAUZP2qRm/ba8QTF9Z/rJow1YHM5XrAWBo=; 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=q/pfxZALlIz6c6yhRK09WOEtYnNyMptv9mxxTPxAtDWTubrnlXP68QjcYlf+1sYDs C/ODcykToU/AP58ZLVo0vD6wQhHiPJJ6OaqW5/G9bQuQU2fH5OIYXIp4apwxzGrmQM 1OSDV7eBvEMqB6qTQiXyi7LanBPudW5kgKf2gJXw49IieMzr9JUaz4c1V9qrz0K1kH GpT6uEbiheuvAb4i0Ka7G5owZHyb1FCgEkWrUrWxv8plAGmOX6j8fe9hiSiAhn/uUO 3qytmilwywN8lok4tucqNUMPC+qC4gJWc0d+Qt8IVo1SxpoHbL8EY5mzAj9yNs1gBE ErCeB2we47zqw== Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9EFC863337 for ; Tue, 26 Jul 2022 14:46:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="cPgDCsfh"; dkim-atps=neutral Received: by mail-wr1-x42c.google.com with SMTP id b26so20017780wrc.2 for ; Tue, 26 Jul 2022 05:46:13 -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=q9EarpEVg/g9/qwGp4A/c3Lb52RzZkR19iEqdrCfwI8=; b=cPgDCsfhm7l7wvGvRePEkOjgmuidNaGDpmJ7ujechj1f07n1xVChFeX0yBDjgX2x82 zCQKwCr6fHErLn5DDjqtK9U6OFOCFMmgcjhV2TAJqiZRW1bi1FC2bdUTgJS8i45MoZfA 94FYy5nZ7O7c+/v2uU7kbLvvidJi6tFEuIclNQiepwu9IXXyMaDdMkJSKPv2Mmv5EwPp S3WAN5aJaoFvWMbWe4LsFhNQHOBbk/xbO4IRY2P7TedLo3jYLUu/KHXjn6T8SILM4el9 ZwqeK3BKvchCI+v9hmbhkdneg7GiSvqr2+m7qtUulVtOwEBY4ebGraMnvOUrN2h+/ivz X+SA== 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=q9EarpEVg/g9/qwGp4A/c3Lb52RzZkR19iEqdrCfwI8=; b=FBLj0QjTNN7VBVqSl0B4ZbDZDj3dupSEr3cwz8ypnygGxW+H6OGbqiN6oa1nrMZ6TW CBeZg3vTe56lZRbRLCiHOLeMz8JK40yygZTGje7nYOY9sP8xmHa58l6fIkqLdQK4Zws1 F7XdSL3BZpoSeIUHQ5ko8wMwqxymf+zpT8t1LKYNO2ayRZHHJw/itpgYLZac+e3FvJx8 tfo8/lcMwnJQIL8o34Fr/5fy/RqoXoYy8ETHvQX92h2YSLulZUYbTBqiwEcoKh2pBOUF eXs1u5R9r77l8xJlQ/ojG9lmINpjRdtRQnJeJ3LudQGhlgWEsLeHt+vRXeVmmRxRjNEn PJLA== X-Gm-Message-State: AJIora/RO7wBoW+lvhsWHDExINhoVfvXmJ374/mGdZgFIk1ucz6WBgNu wDFIEb77h5pTSf4R8BvmEbSeEIclH5+uyQ== X-Google-Smtp-Source: AGRyM1sbd064ImZhYIcm9TJvMXI6dRXPAdrSXBlNQJAa89lilw/bF4Ju1qo0Otma1V83nKcYzYBoNA== X-Received: by 2002:a05:6000:18c1:b0:21e:4712:b284 with SMTP id w1-20020a05600018c100b0021e4712b284mr10234057wrq.545.1658839573061; Tue, 26 Jul 2022 05:46:13 -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.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:46:11 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:48 +0100 Message-Id: <20220726124549.1646-17-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 16/17] ipa: raspberrypi: Remove #define constants 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" Replace all #define constant values with equivalent constexpr definitions. As a drive-by, remove the CAMERA_MODE_NAME_LEN constant as it is unused. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/alsc_status.h | 10 ++++----- src/ipa/raspberrypi/controller/camera_mode.h | 2 -- .../raspberrypi/controller/contrast_status.h | 4 ++-- src/ipa/raspberrypi/controller/rpi/agc.cpp | 22 +++++++++---------- src/ipa/raspberrypi/controller/rpi/agc.h | 4 ++-- src/ipa/raspberrypi/controller/rpi/alsc.cpp | 4 ++-- src/ipa/raspberrypi/controller/rpi/alsc.h | 22 +++++++++---------- src/ipa/raspberrypi/controller/rpi/awb.cpp | 8 +++---- .../raspberrypi/controller/rpi/contrast.cpp | 6 ++--- src/ipa/raspberrypi/raspberrypi.cpp | 2 +- 10 files changed, 41 insertions(+), 43 deletions(-) diff --git a/src/ipa/raspberrypi/controller/alsc_status.h b/src/ipa/raspberrypi/controller/alsc_status.h index 498880daf2d1..e5aa7e37c330 100644 --- a/src/ipa/raspberrypi/controller/alsc_status.h +++ b/src/ipa/raspberrypi/controller/alsc_status.h @@ -11,11 +11,11 @@ * "alsc.status" metadata. */ -#define ALSC_CELLS_X 16 -#define ALSC_CELLS_Y 12 +constexpr unsigned int AlscCellsX = 16; +constexpr unsigned int AlscCellsY = 12; struct AlscStatus { - double r[ALSC_CELLS_Y][ALSC_CELLS_X]; - double g[ALSC_CELLS_Y][ALSC_CELLS_X]; - double b[ALSC_CELLS_Y][ALSC_CELLS_X]; + double r[AlscCellsY][AlscCellsX]; + double g[AlscCellsY][AlscCellsX]; + double b[AlscCellsY][AlscCellsX]; }; diff --git a/src/ipa/raspberrypi/controller/camera_mode.h b/src/ipa/raspberrypi/controller/camera_mode.h index 0ac6c07fb7bf..a6ccf8c1c600 100644 --- a/src/ipa/raspberrypi/controller/camera_mode.h +++ b/src/ipa/raspberrypi/controller/camera_mode.h @@ -16,8 +16,6 @@ * including binning, scaling, cropping etc. */ -#define CAMERA_MODE_NAME_LEN 32 - struct CameraMode { /* bit depth of the raw camera output */ uint32_t bitdepth; diff --git a/src/ipa/raspberrypi/controller/contrast_status.h b/src/ipa/raspberrypi/controller/contrast_status.h index 11d55295963b..ef2a7c680fc2 100644 --- a/src/ipa/raspberrypi/controller/contrast_status.h +++ b/src/ipa/raspberrypi/controller/contrast_status.h @@ -11,7 +11,7 @@ * of contrast stretching based on the AGC histogram. */ -#define CONTRAST_NUM_POINTS 33 +constexpr unsigned int ContrastNumPoints = 33; struct ContrastPoint { uint16_t x; @@ -19,7 +19,7 @@ struct ContrastPoint { }; struct ContrastStatus { - struct ContrastPoint points[CONTRAST_NUM_POINTS]; + struct ContrastPoint points[ContrastNumPoints]; double brightness; double contrast; }; diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index e9a945e3a630..e0c174b6580d 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -28,17 +28,17 @@ LOG_DEFINE_CATEGORY(RPiAgc) #define NAME "rpi.agc" -#define PIPELINE_BITS 13 /* seems to be a 13-bit pipeline */ +static constexpr unsigned int PipelineBits = 13; /* seems to be a 13-bit pipeline */ void AgcMeteringMode::read(boost::property_tree::ptree const ¶ms) { int num = 0; for (auto &p : params.get_child("weights")) { - if (num == AGC_STATS_SIZE) + if (num == AgcStatsSize) LOG(RPiAgc, Fatal) << "AgcConfig: too many weights"; weights[num++] = p.second.get_value(); } - if (num != AGC_STATS_SIZE) + if (num != AgcStatsSize) LOG(RPiAgc, Fatal) << "AgcConfig: insufficient weights"; } @@ -525,11 +525,11 @@ static double computeInitialY(bcm2835_isp_stats *stats, AwbStatus const &awb, * "average" metering (i.e. all pixels equally important). */ double rSum = 0, gSum = 0, bSum = 0, pixelSum = 0; - for (int i = 0; i < AGC_STATS_SIZE; i++) { + for (unsigned int i = 0; i < AgcStatsSize; i++) { double counted = regions[i].counted; - double rAcc = std::min(regions[i].r_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted); - double gAcc = std::min(regions[i].g_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted); - double bAcc = std::min(regions[i].b_sum * gain, ((1 << PIPELINE_BITS) - 1) * counted); + double rAcc = std::min(regions[i].r_sum * gain, ((1 << PipelineBits) - 1) * counted); + double gAcc = std::min(regions[i].g_sum * gain, ((1 << PipelineBits) - 1) * counted); + double bAcc = std::min(regions[i].b_sum * gain, ((1 << PipelineBits) - 1) * counted); rSum += rAcc * weights[i]; gSum += gAcc * weights[i]; bSum += bAcc * weights[i]; @@ -542,7 +542,7 @@ static double computeInitialY(bcm2835_isp_stats *stats, AwbStatus const &awb, double ySum = rSum * awb.gainR * .299 + gSum * awb.gainG * .587 + bSum * awb.gainB * .114; - return ySum / pixelSum / (1 << PIPELINE_BITS); + return ySum / pixelSum / (1 << PipelineBits); } /* @@ -553,13 +553,13 @@ static double computeInitialY(bcm2835_isp_stats *stats, AwbStatus const &awb, * (contrived) cases. */ -#define EV_GAIN_Y_TARGET_LIMIT 0.9 +static constexpr double EvGainYTargetLimit = 0.9; static double constraintComputeGain(AgcConstraint &c, Histogram &h, double lux, double evGain, double &targetY) { targetY = c.yTarget.eval(c.yTarget.domain().clip(lux)); - targetY = std::min(EV_GAIN_Y_TARGET_LIMIT, targetY * evGain); + targetY = std::min(EvGainYTargetLimit, targetY * evGain); double iqm = h.interQuantileMean(c.qLo, c.qHi); return (targetY * NUM_HISTOGRAM_BINS) / iqm; } @@ -578,7 +578,7 @@ void Agc::computeGain(bcm2835_isp_stats *statistics, Metadata *imageMetadata, * that we consider the histogram constraints. */ targetY = config_.yTarget.eval(config_.yTarget.domain().clip(lux.lux)); - targetY = std::min(EV_GAIN_Y_TARGET_LIMIT, targetY * evGain); + targetY = std::min(EvGainYTargetLimit, targetY * evGain); /* * Do this calculation a few times as brightness increase can be diff --git a/src/ipa/raspberrypi/controller/rpi/agc.h b/src/ipa/raspberrypi/controller/rpi/agc.h index 48b33a10c73a..f57afa6dc80c 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.h +++ b/src/ipa/raspberrypi/controller/rpi/agc.h @@ -22,12 +22,12 @@ * number (which is 16). */ -#define AGC_STATS_SIZE 15 +constexpr unsigned int AgcStatsSize = 15; namespace RPiController { struct AgcMeteringMode { - double weights[AGC_STATS_SIZE]; + double weights[AgcStatsSize]; void read(boost::property_tree::ptree const ¶ms); }; diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.cpp b/src/ipa/raspberrypi/controller/rpi/alsc.cpp index 7df89445711a..03ae33501dc0 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/alsc.cpp @@ -23,8 +23,8 @@ LOG_DEFINE_CATEGORY(RPiAlsc) #define NAME "rpi.alsc" -static const int X = ALSC_CELLS_X; -static const int Y = ALSC_CELLS_Y; +static const int X = AlscCellsX; +static const int Y = AlscCellsY; static const int XY = X * Y; static const double InsufficientData = -1.0; diff --git a/src/ipa/raspberrypi/controller/rpi/alsc.h b/src/ipa/raspberrypi/controller/rpi/alsc.h index e17f2fe93379..4e9a715ae0ab 100644 --- a/src/ipa/raspberrypi/controller/rpi/alsc.h +++ b/src/ipa/raspberrypi/controller/rpi/alsc.h @@ -19,7 +19,7 @@ namespace RPiController { struct AlscCalibration { double ct; - double table[ALSC_CELLS_X * ALSC_CELLS_Y]; + double table[AlscCellsX * AlscCellsY]; }; struct AlscConfig { @@ -35,7 +35,7 @@ struct AlscConfig { uint16_t minG; double omega; uint32_t nIter; - double luminanceLut[ALSC_CELLS_X * ALSC_CELLS_Y]; + double luminanceLut[AlscCellsX * AlscCellsY]; double luminanceStrength; std::vector calibrationsCr; std::vector calibrationsCb; @@ -61,7 +61,7 @@ private: AlscConfig config_; bool firstTime_; CameraMode cameraMode_; - double luminanceTable_[ALSC_CELLS_X * ALSC_CELLS_Y]; + double luminanceTable_[AlscCellsX * AlscCellsY]; std::thread asyncThread_; void asyncFunc(); /* asynchronous thread function */ std::mutex mutex_; @@ -87,8 +87,8 @@ private: int frameCount_; /* counts up to startupFrames for Process function */ int frameCount2_; - double syncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X]; - double prevSyncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X]; + double syncResults_[3][AlscCellsY][AlscCellsX]; + double prevSyncResults_[3][AlscCellsY][AlscCellsX]; void waitForAysncThread(); /* * The following are for the asynchronous thread to use, though the main @@ -98,13 +98,13 @@ private: /* copy out the results from the async thread so that it can be restarted */ void fetchAsyncResults(); double ct_; - bcm2835_isp_stats_region statistics_[ALSC_CELLS_Y * ALSC_CELLS_X]; - double asyncResults_[3][ALSC_CELLS_Y][ALSC_CELLS_X]; - double asyncLambdaR_[ALSC_CELLS_X * ALSC_CELLS_Y]; - double asyncLambdaB_[ALSC_CELLS_X * ALSC_CELLS_Y]; + bcm2835_isp_stats_region statistics_[AlscCellsY * AlscCellsX]; + double asyncResults_[3][AlscCellsY][AlscCellsX]; + double asyncLambdaR_[AlscCellsX * AlscCellsY]; + double asyncLambdaB_[AlscCellsX * AlscCellsY]; void doAlsc(); - double lambdaR_[ALSC_CELLS_X * ALSC_CELLS_Y]; - double lambdaB_[ALSC_CELLS_X * ALSC_CELLS_Y]; + double lambdaR_[AlscCellsX * AlscCellsY]; + double lambdaB_[AlscCellsX * AlscCellsY]; }; } /* namespace RPiController */ diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp index c379e6b92649..ad75d55f0976 100644 --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp @@ -18,8 +18,8 @@ LOG_DEFINE_CATEGORY(RPiAwb) #define NAME "rpi.awb" -#define AWB_STATS_SIZE_X DEFAULT_AWB_REGIONS_X -#define AWB_STATS_SIZE_Y DEFAULT_AWB_REGIONS_Y +static constexpr unsigned int AwbStatsSizeX = DEFAULT_AWB_REGIONS_X; +static constexpr unsigned int AwbStatsSizeY = DEFAULT_AWB_REGIONS_Y; /* * todo - the locking in this algorithm needs some tidying up as has been done @@ -357,7 +357,7 @@ static void generateStats(std::vector &zones, bcm2835_isp_stats_region *stats, double minPixels, double minG) { - for (int i = 0; i < AWB_STATS_SIZE_X * AWB_STATS_SIZE_Y; i++) { + for (unsigned int i = 0; i < AwbStatsSizeX * AwbStatsSizeY; i++) { Awb::RGB zone; double counted = stats[i].counted; if (counted >= minPixels) { @@ -599,7 +599,7 @@ void Awb::awbBayes() * valid... not entirely sure about this. */ Pwl prior = interpolatePrior(); - prior *= zones_.size() / (double)(AWB_STATS_SIZE_X * AWB_STATS_SIZE_Y); + prior *= zones_.size() / (double)(AwbStatsSizeX * AwbStatsSizeY); prior.map([](double x, double y) { LOG(RPiAwb, Debug) << "(" << x << "," << y << ")"; }); diff --git a/src/ipa/raspberrypi/controller/rpi/contrast.cpp b/src/ipa/raspberrypi/controller/rpi/contrast.cpp index 04aeb91e4d61..9e60dc5d47e7 100644 --- a/src/ipa/raspberrypi/controller/rpi/contrast.cpp +++ b/src/ipa/raspberrypi/controller/rpi/contrast.cpp @@ -70,15 +70,15 @@ static void fillInStatus(ContrastStatus &status, double brightness, { status.brightness = brightness; status.contrast = contrast; - for (int i = 0; i < CONTRAST_NUM_POINTS - 1; i++) { + for (unsigned int i = 0; i < ContrastNumPoints - 1; i++) { int x = i < 16 ? i * 1024 : (i < 24 ? (i - 16) * 2048 + 16384 : (i - 24) * 4096 + 32768); status.points[i].x = x; status.points[i].y = std::min(65535.0, gammaCurve.eval(x)); } - status.points[CONTRAST_NUM_POINTS - 1].x = 65535; - status.points[CONTRAST_NUM_POINTS - 1].y = 65535; + status.points[ContrastNumPoints - 1].x = 65535; + status.points[ContrastNumPoints - 1].y = 65535; } void Contrast::initialise() diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 951d8c65abfd..9d550354d78e 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1235,7 +1235,7 @@ void IPARPi::applyGamma(const struct ContrastStatus *contrastStatus, ControlList struct bcm2835_isp_gamma gamma; gamma.enabled = 1; - for (int i = 0; i < CONTRAST_NUM_POINTS; i++) { + for (unsigned int i = 0; i < ContrastNumPoints; i++) { gamma.x[i] = contrastStatus->points[i].x; gamma.y[i] = contrastStatus->points[i].y; } From patchwork Tue Jul 26 12:45:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16790 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 996D9C3275 for ; Tue, 26 Jul 2022 12:46:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 544356331E; Tue, 26 Jul 2022 14:46:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658839580; bh=DxE8dBo/rv4Rlcp2pPCH5zov6CAseOL8fxWnuweXAKw=; 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=ld+dT/iiw5UqZJKwDk3tC8MCg2ByEiM3jwtFURvE2DkZqnlMtCQyTfk52Nmki1kOX /LenHkmXUnRgtsRZ3aoiPXf68mMT6r5l5Ra3xpWnhEAO6PyC+M4Xhrqj/CP31x9kKM 76hhFi+f7wQ4zfv3MSPgfLvaMMasqBvTjqXoDA++UEFn7D7MtQTBusJJZoyCAPi+L+ pVd5ruH4/xoAoTxKs2z0vbhNKyGk5QNpvHKhFEh49E4Xkj8Hp9LCM/uWz2tU535cLQ 19/w70vL9vJEYdxqwG3c7KFz8CsBqVU4Bk3Q6dvbgRioi289sOF3oaCcBmfAN/C4x/ g1wd4NlLRsxuQ== Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 87E2363328 for ; Tue, 26 Jul 2022 14:46:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="fV4gTfRa"; dkim-atps=neutral Received: by mail-wm1-x32f.google.com with SMTP id id17so8680588wmb.1 for ; Tue, 26 Jul 2022 05:46:14 -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=bfohaqFOTzxAW86k8d/5H7qneDIMIk4WF0LigIcU0rE=; b=fV4gTfRanl/gF8KC2SO48GI/nb0tjLV75iutkmZdwUKdluoHHr8imfWu8LGexfK2lT +VxZtRjqhQ31Rvyv1NZ8hQcnUhlDeLmDv5r9mtY9OwMsh/VcxPN4kswhO1wSoAQBMBjn z9hNb8XK5q8X8C8XxTI9wRP4ufwfxepa9AxVWxS5wevwhLFBkD1iFIH2RmukfgLqAvj3 9im1eKBvA/qGeR2EiirMtulFK7b5CvBeyuzW9eKNuToxPp56vJDEP4UiZ2/TA55Rd9/R nsNdnwDvZJc0sIZcZW+9yB6NLOl63eyQBLGSAEqnaEsQMrs0tRNBqNuH4xI+oGkXPHAN 3vww== 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=bfohaqFOTzxAW86k8d/5H7qneDIMIk4WF0LigIcU0rE=; b=kkHn4k5Unq75M2SMAXvjKTWBpgqvu9MGVN/XFnGMKLQ6ApTbt40xBZ4Sw2blN1Eu1+ fQkPV1pwXtjsx0eMSlEkBGCP8Q6Q4QzPG3aSJfPwLymnJOaUudaRa+oSWKpr71z9i4wE 7wWtr1KtSLfto4H9xAg2svkT0NvF0qXodkLDRGIrTZwLRybrH7gSaFZ/iujA+bCWxdC0 kLrB4oo5PMwmXVdXBNt9N5gExV80lV9hdFY4NGcOWOjj7CDBuKBzMQnGQ0eC5X0Ce4Dl s7SkdykTKgzGnT0UrLwiLpJnnUH59ddbZEIOYrfgF7Dtb4PmTYJauz1pQjVmHmauN/VE EJUg== X-Gm-Message-State: AJIora/0EXxtl5jj5BKgCRweiYbdxB2+LVWNc4nmQO+NgEsXwcP7yBv6 Kb5Kv3uOj+so71DOFgnz4ABHE3v9SUPMoA== X-Google-Smtp-Source: AGRyM1sSZi+gM9TeyZGfZBpYh160JZZU/REmuKoa0tsoN0P3WxZ5iyAgB59epX01VXwYkRLkm6qZKw== X-Received: by 2002:a05:600c:3549:b0:3a3:16af:d280 with SMTP id i9-20020a05600c354900b003a316afd280mr23985072wmq.142.1658839574000; Tue, 26 Jul 2022 05:46:14 -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.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 05:46:13 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jul 2022 13:45:49 +0100 Message-Id: <20220726124549.1646-18-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 17/17] ipa: raspberrypi: agc: Fix log message prefixes 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" Remove "Agc:" as that gets prefixed by the logging system. s/AgcConfig/AgcMeteringMode/ and s/AgcConfig/AgcMeteringMode where appropriate. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/ipa/raspberrypi/controller/rpi/agc.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp index e0c174b6580d..adec8592626d 100644 --- a/src/ipa/raspberrypi/controller/rpi/agc.cpp +++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp @@ -35,11 +35,11 @@ void AgcMeteringMode::read(boost::property_tree::ptree const ¶ms) int num = 0; for (auto &p : params.get_child("weights")) { if (num == AgcStatsSize) - LOG(RPiAgc, Fatal) << "AgcConfig: too many weights"; + LOG(RPiAgc, Fatal) << "AgcMeteringMode: too many weights"; weights[num++] = p.second.get_value(); } if (num != AgcStatsSize) - LOG(RPiAgc, Fatal) << "AgcConfig: insufficient weights"; + LOG(RPiAgc, Fatal) << "AgcMeteringMode: insufficient weights"; } static std::string @@ -79,10 +79,10 @@ void AgcExposureMode::read(boost::property_tree::ptree const ¶ms) int numAgs = readList(gain, params.get_child("gain")); if (numShutters < 2 || numAgs < 2) LOG(RPiAgc, Fatal) - << "AgcConfig: must have at least two entries in exposure profile"; + << "AgcExposureMode: must have at least two entries in exposure profile"; if (numShutters != numAgs) LOG(RPiAgc, Fatal) - << "AgcConfig: expect same number of exposure and gain entries in exposure profile"; + << "AgcExposureMode: expect same number of exposure and gain entries in exposure profile"; } static std::string @@ -464,7 +464,7 @@ void Agc::housekeepConfig() if (strcmp(meteringModeName_.c_str(), status_.meteringMode)) { auto it = config_.meteringModes.find(meteringModeName_); if (it == config_.meteringModes.end()) - LOG(RPiAgc, Fatal) << "Agc: no metering mode " << meteringModeName_; + LOG(RPiAgc, Fatal) << "No metering mode " << meteringModeName_; meteringMode_ = &it->second; copyString(meteringModeName_, status_.meteringMode, sizeof(status_.meteringMode)); @@ -472,7 +472,7 @@ void Agc::housekeepConfig() if (strcmp(exposureModeName_.c_str(), status_.exposureMode)) { auto it = config_.exposureModes.find(exposureModeName_); if (it == config_.exposureModes.end()) - LOG(RPiAgc, Fatal) << "Agc: no exposure profile " << exposureModeName_; + LOG(RPiAgc, Fatal) << "No exposure profile " << exposureModeName_; exposureMode_ = &it->second; copyString(exposureModeName_, status_.exposureMode, sizeof(status_.exposureMode)); @@ -481,7 +481,7 @@ void Agc::housekeepConfig() auto it = config_.constraintModes.find(constraintModeName_); if (it == config_.constraintModes.end()) - LOG(RPiAgc, Fatal) << "Agc: no constraint list " << constraintModeName_; + LOG(RPiAgc, Fatal) << "No constraint list " << constraintModeName_; constraintMode_ = &it->second; copyString(constraintModeName_, status_.constraintMode, sizeof(status_.constraintMode)); @@ -498,7 +498,7 @@ void Agc::fetchCurrentExposure(Metadata *imageMetadata) DeviceStatus *deviceStatus = imageMetadata->getLocked("device.status"); if (!deviceStatus) - LOG(RPiAgc, Fatal) << "Agc: no device metadata"; + LOG(RPiAgc, Fatal) << "No device metadata"; current_.shutter = deviceStatus->shutterSpeed; current_.analogueGain = deviceStatus->analogueGain; AgcStatus *agcStatus = @@ -513,7 +513,7 @@ void Agc::fetchAwbStatus(Metadata *imageMetadata) awb_.gainG = 1.0; awb_.gainB = 1.0; if (imageMetadata->get("awb.status", awb_) != 0) - LOG(RPiAgc, Debug) << "Agc: no AWB status found"; + LOG(RPiAgc, Debug) << "No AWB status found"; } static double computeInitialY(bcm2835_isp_stats *stats, AwbStatus const &awb, @@ -570,7 +570,7 @@ void Agc::computeGain(bcm2835_isp_stats *statistics, Metadata *imageMetadata, struct LuxStatus lux = {}; lux.lux = 400; /* default lux level to 400 in case no metadata found */ if (imageMetadata->get("lux.status", lux) != 0) - LOG(RPiAgc, Warning) << "Agc: no lux level found"; + LOG(RPiAgc, Warning) << "No lux level found"; Histogram h(statistics->hist[0].g_hist, NUM_HISTOGRAM_BINS); double evGain = status_.ev * config_.baseEv; /*