From patchwork Fri May 27 19:17:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16103 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 BBC92BD160 for ; Fri, 27 May 2022 19:17:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6120165635; Fri, 27 May 2022 21:17:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653679069; bh=JWNocmS/1zMKAmAH7+gCe5WZ8Ds2o2RQRGf/ObWD9Hw=; 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=mM+Ry3IDPqAB5o9vbIfAd4fTM6QdLH9HIdzyn2+h2xrqh0syg4leDLqYVS8JWcRN0 pQcfQ7aiB+nCBsr2cAtoq9LTlepcSZ5t7cjOQ7J4arv9jExDSgcnrjxEGTXvxKOuUn sR2mUfvqaQ4vdCDKCqK9co9AaheLjAvrPU0TZFWZYYvdMwWr9EhWDNkuSmlDXSMHCM 1qFroj9ermRU3jmp0LwzheqeCJcoUx0m/b1IuzOwMvKsc0Fy6Ja0g0R1bTeq9CLoEM FZpbWAXkTjbGk0R4QduHgktLa29At4MyNKrWOiWsHv/8AvrZZRie0WgcFiaxyRIcjK JJRi1rvVj76AQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C297A633A5 for ; Fri, 27 May 2022 21:17:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="gPD+3O+C"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [90.164.63.43]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 69FE132A; Fri, 27 May 2022 21:17:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653679065; bh=JWNocmS/1zMKAmAH7+gCe5WZ8Ds2o2RQRGf/ObWD9Hw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gPD+3O+C9Pfoo6V418PWKW3Gek1FwoXWWq75QfhVZPBzJaxvtdlpsHHw4Asz7BPg/ 9JlA48L5o3epop72q7vIo8teXqmIG2U9YJ0Kk7wn0lQ9myzZawfm7mTqT1jW+RTxVF MMom+9yK/gVhAJYr3lPByUBFafgclIWRE8O37UnU= To: libcamera-devel@lists.libcamera.org Date: Fri, 27 May 2022 21:17:38 +0200 Message-Id: <20220527191740.242300-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220527191740.242300-1-umang.jain@ideasonboard.com> References: <20220527191740.242300-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 1/3] ipa: ipu3: Separate out frame context queue as a distinct class 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: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" There are cases where we need more checks and balance to be carried out by the frame context queue class. For that, separate it out as a distinct class on which we can build upon. For now, a minimialistic implementation is provided with .get(frame) helper which returns a IPAFrameContext for the required frame. Going ahead more such helpers can be provided to access/modify the frame context queue. Signed-off-by: Umang Jain Reviewed-by: Paul Elder Reviewed-by: Jean-Michel Hautbois --- src/ipa/ipu3/ipa_context.cpp | 49 ++++++++++++++++++++++++++++++++++-- src/ipa/ipu3/ipa_context.h | 11 +++++++- src/ipa/ipu3/ipu3.cpp | 6 ++--- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp index 13cdb835..e5010e3f 100644 --- a/src/ipa/ipu3/ipa_context.cpp +++ b/src/ipa/ipu3/ipa_context.cpp @@ -7,12 +7,18 @@ #include "ipa_context.h" +#include + /** * \file ipa_context.h * \brief Context and state information shared between the algorithms */ -namespace libcamera::ipa::ipu3 { +namespace libcamera { + +LOG_DECLARE_CATEGORY(IPAIPU3) + +namespace ipa::ipu3 { /** * \struct IPASessionConfiguration @@ -211,4 +217,43 @@ IPAFrameContext::IPAFrameContext(uint32_t id, const ControlList &reqControls) * \brief Analogue gain multiplier */ -} /* namespace libcamera::ipa::ipu3 */ +/** + * \brief FCQueue constructor + */ +FCQueue::FCQueue() +{ + clear(); +} + +/** + * Retrieve the IPAFrameContext for the frame + * \param[in] frame Frame number for which the IPAFrameContext needs to + * retrieved + * + * \return Reference to the IPAFrameContext + */ +IPAFrameContext &FCQueue::get(uint32_t frame) +{ + IPAFrameContext &frameContext = this->at(frame % kMaxFrameContexts); + + if (frame != frameContext.frame) { + LOG(IPAIPU3, Warning) + << "Got wrong frame context for frame" << frame + << " or frame context doesn't exist yet"; + } + + return frameContext; +} + +/** + * \brief Clear the FCQueue by resetting all the entries in the ring-buffer + */ +void FCQueue::clear() +{ + IPAFrameContext initFrameContext; + this->fill(initFrameContext); +} + +} /* namespace ipa::ipu3 */ + +} /* namespace libcamera */ diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h index 42e11141..61454b41 100644 --- a/src/ipa/ipu3/ipa_context.h +++ b/src/ipa/ipu3/ipa_context.h @@ -89,11 +89,20 @@ struct IPAFrameContext { ControlList frameControls; }; +class FCQueue : public std::array +{ +public: + FCQueue(); + + void clear(); + IPAFrameContext &get(uint32_t frame); +}; + struct IPAContext { IPASessionConfiguration configuration; IPAActiveState activeState; - std::array frameContexts; + FCQueue frameContexts; }; } /* namespace ipa::ipu3 */ diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 2f6bb672..c48d2f62 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -456,8 +456,8 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo, /* Clean IPAActiveState at each reconfiguration. */ context_.activeState = {}; - IPAFrameContext initFrameContext; - context_.frameContexts.fill(initFrameContext); + context_.frameContexts.clear(); + if (!validateSensorControls()) { LOG(IPAIPU3, Error) << "Sensor control validation failed."; @@ -569,7 +569,7 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, const ipu3_uapi_stats_3a *stats = reinterpret_cast(mem.data()); - IPAFrameContext &frameContext = context_.frameContexts[frame % kMaxFrameContexts]; + IPAFrameContext &frameContext = context_.frameContexts.get(frame); if (frameContext.frame != frame) LOG(IPAIPU3, Warning) << "Frame " << frame << " does not match its frame context"; From patchwork Fri May 27 19:17:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16104 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 5D1A9C3256 for ; Fri, 27 May 2022 19:17:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5143D633A5; Fri, 27 May 2022 21:17:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653679070; bh=6QaKR0Oc06NXJj9OaMhXbRJg5e5/1b7qBXL9P9S32Ik=; 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=KWk4hbcUa4sVe4pVTfT9IRMPLvs2uitClSOnWEF3FvH3L7AilnxHUEd8ep6AqCpLT Pl1yF7ouoBXZHxpKwhpwT02759ejmCAlOxLLOHeX1dEKEHF0vPKnTD/GhjzWhrCvn6 cC1wvH+x/Nj6M4w1gR+F5zFhUgGk1208u6xq08S4Eu5/pUS1KNTlhzufRfyYI0dP0o h+YpP5nMyrW6anZUY3AM+UJvkN1axEYCbBF0Pc83Lfm5fjFZywOZXK+MJATagbRtIA BH2StG5p1NToxGRo1VzL3CUCM37MQUxcs6/31mWjXclewmwTjitZqKxr8+WVakd8Wy OKagTTwywW0SA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2AD09633A2 for ; Fri, 27 May 2022 21:17:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WBSVcvyl"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [90.164.63.43]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D023A32A; Fri, 27 May 2022 21:17:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653679067; bh=6QaKR0Oc06NXJj9OaMhXbRJg5e5/1b7qBXL9P9S32Ik=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WBSVcvyl2IG/0AKOfqr+GMdW1kfluDxXaCv+HdW5E/DCZOgBh2ibKD/QUtCOtSibs b5FfvxDuijW7HqSwbB+hqA4hjTKAnQRhMLAZ9EJtln8hmfuI5mqJXI2on+ujYcKh52 1DBYSrSVHG9A6JVEPTIWXjoNybRGhF4qQH9FPUO8= To: libcamera-devel@lists.libcamera.org Date: Fri, 27 May 2022 21:17:39 +0200 Message-Id: <20220527191740.242300-3-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220527191740.242300-1-umang.jain@ideasonboard.com> References: <20220527191740.242300-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 2/3] ipa: ipu3: ipa_context: Extend FCQueue::get() 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: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Extend the FCQueue::get() to return a IPAFrameContext for a non-existent frame. The .get() should be able to figure out if a existent frame context is asked for, or to create a new frame context based on the next available position. To keep track of next available position in the queue, use of head and tail pointer are used. We specifically want to have access to the queue through the .get() function hence operator[] is deleted for FCQueue as part of this patch as well. Signed-off-by: Umang Jain --- src/ipa/ipu3/ipa_context.cpp | 81 +++++++++++++++++++++++++++++++++--- src/ipa/ipu3/ipa_context.h | 5 +++ src/ipa/ipu3/ipu3.cpp | 4 +- 3 files changed, 83 insertions(+), 7 deletions(-) diff --git a/src/ipa/ipu3/ipa_context.cpp b/src/ipa/ipu3/ipa_context.cpp index e5010e3f..dcce6b48 100644 --- a/src/ipa/ipu3/ipa_context.cpp +++ b/src/ipa/ipu3/ipa_context.cpp @@ -217,32 +217,96 @@ IPAFrameContext::IPAFrameContext(uint32_t id, const ControlList &reqControls) * \brief Analogue gain multiplier */ +/** + * \class FCQueue + * \brief A FIFO circular queue holding IPAFrameContext(s) + * + * FCQueue holds all the IPAFrameContext(s) related to frames required + * to be processed by the IPA at a given point. A IPAFrameContext is created + * on the first call FCQueue::get(frame) for that frame. Subsequent calls to + * FCQueue::get() with the same frame number shall return the IPAFrameContext + * previously created until the frame is marked as complete through + * FCQueue::completeFrame(frame). + */ + +/** + * \var FCQueue::head + * \brief A pointer to the a IPAFrameContext next expected to complete + */ + +/** + * \var FCQueue::tail + * \brief A pointer to the latest IPAFrameContext created + */ + /** * \brief FCQueue constructor */ FCQueue::FCQueue() + : head(nullptr), tail(nullptr) { clear(); } /** - * Retrieve the IPAFrameContext for the frame + * \brief Retrieve the IPAFrameContext for the frame * \param[in] frame Frame number for which the IPAFrameContext needs to * retrieved * + * This functions returns the IPAFrameContext for the desired frame. If the + * frame context does not exists in the queue, the next available reference + * of the position in the queue, is returned. It is the responsibility of the + * caller to fill the correct IPAFrameContext parameters of newly returned + * IPAFrameContext. + * * \return Reference to the IPAFrameContext */ IPAFrameContext &FCQueue::get(uint32_t frame) { - IPAFrameContext &frameContext = this->at(frame % kMaxFrameContexts); + if (frame <= tail->frame) { + IPAFrameContext &frameContext = this->at(frame % kMaxFrameContexts); + if (frame != frameContext.frame) + LOG(IPAIPU3, Warning) + << "Got wrong frame context for frame " << frame; + return frameContext; + } else { + /* + * Frame context doesn't exist yet so get the next available + * position in the queue. + */ + tail = &this->at((tail->frame + 1) % kMaxFrameContexts); + tail->frame = frame; - if (frame != frameContext.frame) { + /* Avoid over-queuing of frame contexts */ + if (tail->frame > kMaxFrameContexts && + (tail->frame - head->frame) >= kMaxFrameContexts) { + LOG(IPAIPU3, Error) << "FCQueue is full!"; + + /* \todo: Determine return reference? or make it fatal? */ + } + + return *tail; + } +} + +/** + * \brief Notifies the FCQueue that a frame has been completed + * \param[in] frame The completed frame number + */ +void FCQueue::completeFrame(uint32_t frame) +{ + if (head->frame != frame) LOG(IPAIPU3, Warning) - << "Got wrong frame context for frame" << frame - << " or frame context doesn't exist yet"; + << "Frame " << frame << " completed out-of-sync?"; + + if (frame > tail->frame) { + LOG(IPAIPU3, Error) + << "Completing a frame " << frame + << " not present in the queue is disallowed"; + return; } - return frameContext; + head = &this->get(frame + 1); } /** @@ -252,6 +316,11 @@ void FCQueue::clear() { IPAFrameContext initFrameContext; this->fill(initFrameContext); + + /* Intialise 0th index to frame 0 */ + this->at(0).frame = 0; + tail = &this->at(0); + head = tail; } } /* namespace ipa::ipu3 */ diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h index 61454b41..b36ec61d 100644 --- a/src/ipa/ipu3/ipa_context.h +++ b/src/ipa/ipu3/ipa_context.h @@ -93,9 +93,14 @@ class FCQueue : public std::array { public: FCQueue(); + FCQueue &operator[](const FCQueue &) = delete; void clear(); + void completeFrame(uint32_t frame); IPAFrameContext &get(uint32_t frame); + + IPAFrameContext *head; + IPAFrameContext *tail; }; struct IPAContext { diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index c48d2f62..e09c5d05 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -605,6 +605,8 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, */ metadataReady.emit(frame, ctrls); + + context_.frameContexts.completeFrame(frame); } /** @@ -618,7 +620,7 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, void IPAIPU3::queueRequest(const uint32_t frame, const ControlList &controls) { /* \todo Start processing for 'frame' based on 'controls'. */ - context_.frameContexts[frame % kMaxFrameContexts] = { frame, controls }; + context_.frameContexts.get(frame) = { frame, controls }; } /** From patchwork Fri May 27 19:17:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16105 X-Patchwork-Delegate: umang.jain@ideasonboard.com 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 787B4C326D for ; Fri, 27 May 2022 19:17:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B4C5B6563A; Fri, 27 May 2022 21:17:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653679071; bh=x4t25g4YYcC0+UqEd27p/Zay/WDQ3WTa/68IHZ/ZuVM=; 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=NCCmcc4eqLJqWAugUySIsdUCLMQJ3GH1SSh3wwGhPwmujfVI65IwyUwvuuM7ASr4b AkZFgrjJ+vpm0dtbtCBU3+YFTZEjbRtk52My1icGPKHbjsa3sp+nDCxoNhbd9o5pK4 pzWRFrTwZ1ymlENodosO8ktFzFyRghp9iDB59fi3xubtbrHYh7SKW0JreHD7VZkVvK WacAYqSG5vxWRWF2wU+iqfpY9yYPRojQf3tW8VS6EF08yvIzo33+2YCpY/VFmQG+cE 8kaxxPsaTsHbPY4wJDEv4YG6nVaRXofqiWZbvzf9xUfUYPWe8Ag2KNQZPYAfOlrB+n NoZYbD28ZJpGA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 609EE633A3 for ; Fri, 27 May 2022 21:17:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="dFHmvOBQ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [90.164.63.43]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C5B6F32A; Fri, 27 May 2022 21:17:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653679068; bh=x4t25g4YYcC0+UqEd27p/Zay/WDQ3WTa/68IHZ/ZuVM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dFHmvOBQ2o/6OZhFTkPp7wljoe9moKrJIHHAV791kK8+VHROIaVXZ9OhC7a+GuXdQ Yz2dbCJz75BjuzMY12c+8ntvV2Dnl+KmJOJn4KnD5DaXUjgWfwtt8Z4tXrtLyx3I9v fkhSoHno0L0Nvr1tvnXeg+4aLOZfqND08iQzi1m8= To: libcamera-devel@lists.libcamera.org Date: Fri, 27 May 2022 21:17:40 +0200 Message-Id: <20220527191740.242300-4-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220527191740.242300-1-umang.jain@ideasonboard.com> References: <20220527191740.242300-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 3/3] ipa: algorithm: process() should take in frame number instead of context 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: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This will enable algorithms to extract a frame context from the FCQueue using the frame number. This is required because algorithms can operate on different frames at different points in time (according to frame latency they need to respect). Signed-off-by: Umang Jain Reviewed-by: Paul Elder Reviewed-by: Jean-Michel Hautbois --- src/ipa/ipu3/algorithms/af.cpp | 2 +- src/ipa/ipu3/algorithms/af.h | 2 +- src/ipa/ipu3/algorithms/agc.cpp | 13 +++++++------ src/ipa/ipu3/algorithms/agc.h | 4 ++-- src/ipa/ipu3/algorithms/algorithm.h | 4 ++-- src/ipa/ipu3/algorithms/awb.cpp | 2 +- src/ipa/ipu3/algorithms/awb.h | 2 +- src/ipa/ipu3/algorithms/tone_mapping.cpp | 2 +- src/ipa/ipu3/algorithms/tone_mapping.h | 2 +- src/ipa/ipu3/ipu3.cpp | 2 +- src/ipa/libipa/algorithm.cpp | 2 +- src/ipa/libipa/algorithm.h | 6 +++--- src/ipa/rkisp1/algorithms/agc.cpp | 3 +-- src/ipa/rkisp1/algorithms/agc.h | 2 +- src/ipa/rkisp1/algorithms/algorithm.h | 5 ++--- src/ipa/rkisp1/algorithms/awb.cpp | 2 +- src/ipa/rkisp1/algorithms/awb.h | 2 +- src/ipa/rkisp1/rkisp1.cpp | 2 +- 18 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/ipa/ipu3/algorithms/af.cpp b/src/ipa/ipu3/algorithms/af.cpp index d07521a0..24462c6b 100644 --- a/src/ipa/ipu3/algorithms/af.cpp +++ b/src/ipa/ipu3/algorithms/af.cpp @@ -420,7 +420,7 @@ bool Af::afIsOutOfFocus(IPAContext context) * * [1] Hill Climbing Algorithm, https://en.wikipedia.org/wiki/Hill_climbing */ -void Af::process(IPAContext &context, [[maybe_unused]] IPAFrameContext *frameContext, +void Af::process(IPAContext &context, [[maybe_unused]] uint32_t frame, const ipu3_uapi_stats_3a *stats) { /* Evaluate the AF buffer length */ diff --git a/src/ipa/ipu3/algorithms/af.h b/src/ipa/ipu3/algorithms/af.h index ccf015f3..69aeb3e2 100644 --- a/src/ipa/ipu3/algorithms/af.h +++ b/src/ipa/ipu3/algorithms/af.h @@ -32,7 +32,7 @@ public: void prepare(IPAContext &context, ipu3_uapi_params *params) override; int configure(IPAContext &context, const IPAConfigInfo &configInfo) override; - void process(IPAContext &context, IPAFrameContext *frameContext, + void process(IPAContext &context, uint32_t frame, const ipu3_uapi_stats_3a *stats) override; private: diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp index f16be534..41766007 100644 --- a/src/ipa/ipu3/algorithms/agc.cpp +++ b/src/ipa/ipu3/algorithms/agc.cpp @@ -183,13 +183,14 @@ utils::Duration Agc::filterExposure(utils::Duration exposureValue) * \param[in] yGain The gain calculated based on the relative luminance target * \param[in] iqMeanGain The gain calculated based on the relative luminance target */ -void Agc::computeExposure(IPAContext &context, IPAFrameContext *frameContext, - double yGain, double iqMeanGain) +void Agc::computeExposure(IPAContext &context, uint32_t frame, double yGain, + double iqMeanGain) { const IPASessionConfiguration &configuration = context.configuration; /* Get the effective exposure and gain applied on the sensor. */ - uint32_t exposure = frameContext->sensor.exposure; - double analogueGain = frameContext->sensor.gain; + IPAFrameContext &frameContext = context.frameContexts.get(frame); + uint32_t exposure = frameContext.sensor.exposure; + double analogueGain = frameContext.sensor.gain; /* Use the highest of the two gain estimates. */ double evGain = std::max(yGain, iqMeanGain); @@ -323,7 +324,7 @@ double Agc::estimateLuminance(IPAActiveState &activeState, * Identify the current image brightness, and use that to estimate the optimal * new exposure and gain for the scene. */ -void Agc::process(IPAContext &context, [[maybe_unused]] IPAFrameContext *frameContext, +void Agc::process(IPAContext &context, [[maybe_unused]] uint32_t frame, const ipu3_uapi_stats_3a *stats) { /* @@ -359,7 +360,7 @@ void Agc::process(IPAContext &context, [[maybe_unused]] IPAFrameContext *frameCo break; } - computeExposure(context, frameContext, yGain, iqMeanGain); + computeExposure(context, frame, yGain, iqMeanGain); frameCount_++; } diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h index 105ae0f2..8ef2a2d8 100644 --- a/src/ipa/ipu3/algorithms/agc.h +++ b/src/ipa/ipu3/algorithms/agc.h @@ -28,14 +28,14 @@ public: ~Agc() = default; int configure(IPAContext &context, const IPAConfigInfo &configInfo) override; - void process(IPAContext &context, IPAFrameContext *frameContext, + void process(IPAContext &context, uint32_t frame, const ipu3_uapi_stats_3a *stats) override; private: double measureBrightness(const ipu3_uapi_stats_3a *stats, const ipu3_uapi_grid_config &grid) const; utils::Duration filterExposure(utils::Duration currentExposure); - void computeExposure(IPAContext &context, IPAFrameContext *frameContext, + void computeExposure(IPAContext &context, uint32_t frame, double yGain, double iqMeanGain); double estimateLuminance(IPAActiveState &activeState, const ipu3_uapi_grid_config &grid, diff --git a/src/ipa/ipu3/algorithms/algorithm.h b/src/ipa/ipu3/algorithms/algorithm.h index 234b2bd7..3e0c60d3 100644 --- a/src/ipa/ipu3/algorithms/algorithm.h +++ b/src/ipa/ipu3/algorithms/algorithm.h @@ -17,8 +17,8 @@ namespace libcamera { namespace ipa::ipu3 { -using Algorithm = libcamera::ipa::Algorithm; } /* namespace ipa::ipu3 */ diff --git a/src/ipa/ipu3/algorithms/awb.cpp b/src/ipa/ipu3/algorithms/awb.cpp index 5c232d92..35f35ebe 100644 --- a/src/ipa/ipu3/algorithms/awb.cpp +++ b/src/ipa/ipu3/algorithms/awb.cpp @@ -387,7 +387,7 @@ void Awb::calculateWBGains(const ipu3_uapi_stats_3a *stats) /** * \copydoc libcamera::ipa::Algorithm::process */ -void Awb::process(IPAContext &context, [[maybe_unused]] IPAFrameContext *frameContext, +void Awb::process(IPAContext &context, [[maybe_unused]] uint32_t frame, const ipu3_uapi_stats_3a *stats) { calculateWBGains(stats); diff --git a/src/ipa/ipu3/algorithms/awb.h b/src/ipa/ipu3/algorithms/awb.h index 9a50a985..f263540c 100644 --- a/src/ipa/ipu3/algorithms/awb.h +++ b/src/ipa/ipu3/algorithms/awb.h @@ -40,7 +40,7 @@ public: int configure(IPAContext &context, const IPAConfigInfo &configInfo) override; void prepare(IPAContext &context, ipu3_uapi_params *params) override; - void process(IPAContext &context, IPAFrameContext *frameContext, + void process(IPAContext &context, uint32_t frame, const ipu3_uapi_stats_3a *stats) override; private: diff --git a/src/ipa/ipu3/algorithms/tone_mapping.cpp b/src/ipa/ipu3/algorithms/tone_mapping.cpp index f86e79b2..0f70b8aa 100644 --- a/src/ipa/ipu3/algorithms/tone_mapping.cpp +++ b/src/ipa/ipu3/algorithms/tone_mapping.cpp @@ -78,7 +78,7 @@ void ToneMapping::prepare([[maybe_unused]] IPAContext &context, * The tone mapping look up table is generated as an inverse power curve from * our gamma setting. */ -void ToneMapping::process(IPAContext &context, [[maybe_unused]] IPAFrameContext *frameContext, +void ToneMapping::process(IPAContext &context, [[maybe_unused]] uint32_t frame, [[maybe_unused]] const ipu3_uapi_stats_3a *stats) { /* diff --git a/src/ipa/ipu3/algorithms/tone_mapping.h b/src/ipa/ipu3/algorithms/tone_mapping.h index d7d48006..61474085 100644 --- a/src/ipa/ipu3/algorithms/tone_mapping.h +++ b/src/ipa/ipu3/algorithms/tone_mapping.h @@ -20,7 +20,7 @@ public: int configure(IPAContext &context, const IPAConfigInfo &configInfo) override; void prepare(IPAContext &context, ipu3_uapi_params *params) override; - void process(IPAContext &context, IPAFrameContext *frameContext, + void process(IPAContext &context, uint32_t frame, const ipu3_uapi_stats_3a *stats) override; private: diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index e09c5d05..4f33b1a6 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -582,7 +582,7 @@ void IPAIPU3::processStatsBuffer(const uint32_t frame, ControlList ctrls(controls::controls); for (auto const &algo : algorithms_) - algo->process(context_, &frameContext, stats); + algo->process(context_, frame, stats); setControls(frame); diff --git a/src/ipa/libipa/algorithm.cpp b/src/ipa/libipa/algorithm.cpp index cce2ed62..c0a9bbeb 100644 --- a/src/ipa/libipa/algorithm.cpp +++ b/src/ipa/libipa/algorithm.cpp @@ -64,7 +64,7 @@ namespace ipa { * \fn Algorithm::process() * \brief Process ISP statistics, and run algorithm operations * \param[in] context The shared IPA context - * \param[in] frameContext The current frame's context + * \param[in] frame The current frame id * \param[in] stats The IPA statistics and ISP results * * This function is called while camera is running for every frame processed by diff --git a/src/ipa/libipa/algorithm.h b/src/ipa/libipa/algorithm.h index 032a05b5..d1ca0883 100644 --- a/src/ipa/libipa/algorithm.h +++ b/src/ipa/libipa/algorithm.h @@ -10,8 +10,8 @@ namespace libcamera { namespace ipa { -template +template + class Algorithm { public: @@ -29,7 +29,7 @@ public: } virtual void process([[maybe_unused]] Context &context, - [[maybe_unused]] FrameContext *frameContext, + [[maybe_unused]] uint32_t frame, [[maybe_unused]] const Stats *stats) { } diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp index b5a184d9..9418b533 100644 --- a/src/ipa/rkisp1/algorithms/agc.cpp +++ b/src/ipa/rkisp1/algorithms/agc.cpp @@ -280,8 +280,7 @@ double Agc::measureBrightness(const rkisp1_cif_isp_hist_stat *hist) const * Identify the current image brightness, and use that to estimate the optimal * new exposure and gain for the scene. */ -void Agc::process(IPAContext &context, - [[maybe_unused]] IPAFrameContext *frameContext, +void Agc::process(IPAContext &context, [[maybe_unused]] uint32_t frame, const rkisp1_stat_buffer *stats) { const rkisp1_cif_isp_stat *params = &stats->params; diff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h index 22c02779..a749f1c3 100644 --- a/src/ipa/rkisp1/algorithms/agc.h +++ b/src/ipa/rkisp1/algorithms/agc.h @@ -29,7 +29,7 @@ public: int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override; void prepare(IPAContext &context, rkisp1_params_cfg *params) override; - void process(IPAContext &context, IPAFrameContext *frameContext, + void process(IPAContext &context, uint32_t frame, const rkisp1_stat_buffer *stats) override; private: diff --git a/src/ipa/rkisp1/algorithms/algorithm.h b/src/ipa/rkisp1/algorithms/algorithm.h index 68e3a44e..069c744c 100644 --- a/src/ipa/rkisp1/algorithms/algorithm.h +++ b/src/ipa/rkisp1/algorithms/algorithm.h @@ -19,9 +19,8 @@ namespace libcamera { namespace ipa::rkisp1 { -using Algorithm = libcamera::ipa::Algorithm; +using Algorithm = libcamera::ipa::Algorithm; } /* namespace ipa::rkisp1 */ diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp index 88441382..1e7fd11a 100644 --- a/src/ipa/rkisp1/algorithms/awb.cpp +++ b/src/ipa/rkisp1/algorithms/awb.cpp @@ -120,7 +120,7 @@ void Awb::prepare(IPAContext &context, rkisp1_params_cfg *params) * \copydoc libcamera::ipa::Algorithm::process */ void Awb::process([[maybe_unused]] IPAContext &context, - [[maybe_unused]] IPAFrameContext *frameCtx, + [[maybe_unused]] uint32_t frame, const rkisp1_stat_buffer *stats) { const rkisp1_cif_isp_stat *params = &stats->params; diff --git a/src/ipa/rkisp1/algorithms/awb.h b/src/ipa/rkisp1/algorithms/awb.h index 7647842f..82921f34 100644 --- a/src/ipa/rkisp1/algorithms/awb.h +++ b/src/ipa/rkisp1/algorithms/awb.h @@ -23,7 +23,7 @@ public: int configure(IPAContext &context, const IPACameraSensorInfo &configInfo) override; void prepare(IPAContext &context, rkisp1_params_cfg *params) override; - void process(IPAContext &context, IPAFrameContext *frameCtx, + void process(IPAContext &context, uint32_t frame, const rkisp1_stat_buffer *stats) override; private: diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index c818a6d7..ad33d817 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -272,7 +272,7 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId unsigned int aeState = 0; for (auto const &algo : algorithms_) - algo->process(context_, nullptr, stats); + algo->process(context_, frame, stats); setControls(frame);