From patchwork Fri Oct 24 08:50:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Klug X-Patchwork-Id: 24774 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 6E391C3259 for ; Fri, 24 Oct 2025 08:52:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3F5E4608B5; Fri, 24 Oct 2025 10:52:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qaiHyUwk"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 44FFF6089B for ; Fri, 24 Oct 2025 10:52:00 +0200 (CEST) Received: from ideasonboard.com (unknown [IPv6:2a00:6020:448c:6c00:7edc:62f4:c118:1549]) by perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id A6FE61E27; Fri, 24 Oct 2025 10:50:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1761295814; bh=s/k8oJsmDY4Ef6CFQGyygXBrsoR+qmcoYHs9Uyr1+qY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qaiHyUwkcLOVEVvLYMd8xluSxOMaOXZTW4cV2vyA9undNwFQKL7QRfpPRx0QxxJCu c/9Zg5NEAa7XaQ++SkH8X5egyoOyB5jF4F5vMPC1gGJjBmNia16vI0+DU7GbwSUGL2 sRPvW4XdRRtxnDcndjO/UG/iD7uRCodlpamAsoV8= From: Stefan Klug To: libcamera-devel@lists.libcamera.org Cc: Stefan Klug Subject: [PATCH v1 08/35] libipa: fc_queue: Add trailing underscore to private members of FrameContext Date: Fri, 24 Oct 2025 10:50:32 +0200 Message-ID: <20251024085130.995967-9-stefan.klug@ideasonboard.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20251024085130.995967-1-stefan.klug@ideasonboard.com> References: <20251024085130.995967-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" It is not immediately obvious that FCQueue accesses private members of the FrameContext class with the help of the friend declaration. This gets even more confusing when such a member is shadowed by a declaration in the actual IPA FrameContext class. Improve that by accessing the FrameContext members via references to that type. Additionally add an underscore to the variable names like we do on other members and which allows us to create a frame() accessor without a name clash in an upcoming commit. Signed-off-by: Stefan Klug --- src/ipa/libipa/fc_queue.cpp | 2 +- src/ipa/libipa/fc_queue.h | 51 ++++++++++++++++++++----------------- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/ipa/libipa/fc_queue.cpp b/src/ipa/libipa/fc_queue.cpp index 0365e9197748..39222c2ed204 100644 --- a/src/ipa/libipa/fc_queue.cpp +++ b/src/ipa/libipa/fc_queue.cpp @@ -34,7 +34,7 @@ namespace ipa { * update any specific action for this frame, and finally to update the metadata * control lists when the frame is fully completed. * - * \var FrameContext::frame + * \var FrameContext::frame_ * \brief The frame number */ diff --git a/src/ipa/libipa/fc_queue.h b/src/ipa/libipa/fc_queue.h index 1f4f84c27fbc..1128e42f8ca6 100644 --- a/src/ipa/libipa/fc_queue.h +++ b/src/ipa/libipa/fc_queue.h @@ -24,8 +24,8 @@ class FCQueue; struct FrameContext { private: template friend class FCQueue; - uint32_t frame; - bool initialised = false; + uint32_t frame_; + bool initialised_ = false; }; template @@ -40,14 +40,15 @@ public: void clear() { for (FC &ctx : contexts_) { - ctx.initialised = false; - ctx.frame = 0; + ctx.initialised_ = false; + ctx.frame_ = 0; } } FC &alloc(const uint32_t frame) { - FC &frameContext = contexts_[frame % contexts_.size()]; + FC &fc = contexts_[frame % contexts_.size()]; + FrameContext &frameContext = fc; /* * Do not re-initialise if a get() call has already fetched this @@ -60,18 +61,19 @@ public: * time the application has queued a request. Does this deserve * an error condition ? */ - if (frame != 0 && frame <= frameContext.frame) + if (frame != 0 && frame <= frameContext.frame_) LOG(FCQueue, Warning) << "Frame " << frame << " already initialised"; else - init(frameContext, frame); + init(fc, frame); - return frameContext; + return fc; } FC &get(uint32_t frame) { - FC &frameContext = contexts_[frame % contexts_.size()]; + FC &fc = contexts_[frame % contexts_.size()]; + FrameContext &frameContext = fc; /* * If the IPA algorithms try to access a frame context slot which @@ -81,28 +83,28 @@ public: * queueing more requests to the IPA than the frame context * queue size. */ - if (frame < frameContext.frame) + if (frame < frameContext.frame_) LOG(FCQueue, Fatal) << "Frame context for " << frame << " has been overwritten by " - << frameContext.frame; + << frameContext.frame_; - if (frame == 0 && !frameContext.initialised) { + if (frame == 0 && !frameContext.initialised_) { /* * If the IPA calls get() at start() time it will get an * un-intialized FrameContext as the below "frame == - * frameContext.frame" check will return success because - * FrameContexts are zeroed at creation time. + * frameContext.frame_" check will return success + * because FrameContexts are zeroed at creation time. * * Make sure the FrameContext gets initialised if get() * is called before alloc() by the IPA for frame#0. */ - init(frameContext, frame); + init(fc, frame); - return frameContext; + return fc; } - if (frame == frameContext.frame) - return frameContext; + if (frame == frameContext.frame_) + return fc; /* * The frame context has been retrieved before it was @@ -116,17 +118,18 @@ public: LOG(FCQueue, Warning) << "Obtained an uninitialised FrameContext for " << frame; - init(frameContext, frame); + init(fc, frame); - return frameContext; + return fc; } private: - void init(FC &frameContext, const uint32_t frame) + void init(FC &fc, const uint32_t frame) { - frameContext = {}; - frameContext.frame = frame; - frameContext.initialised = true; + fc = {}; + FrameContext &frameContext = fc; + frameContext.frame_ = frame; + frameContext.initialised_ = true; } std::vector contexts_;