{"id":17428,"url":"https://patchwork.libcamera.org/api/patches/17428/?format=json","web_url":"https://patchwork.libcamera.org/patch/17428/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220927023642.12341-18-laurent.pinchart@ideasonboard.com>","date":"2022-09-27T02:36:26","name":"[libcamera-devel,v5,17/33] ipa: libipa: Pass FCQueue size as template argument","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"ca26d569a75f6496d778b587d8cd4f379a434fa1","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17428/mbox/","series":[{"id":3506,"url":"https://patchwork.libcamera.org/api/series/3506/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3506","date":"2022-09-27T02:36:09","name":"ipa: Frame context queue, IPU3 & RkISP consolidation, and RkISP1 improvements","version":5,"mbox":"https://patchwork.libcamera.org/series/3506/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17428/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17428/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 4AFC9C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Sep 2022 02:37:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 05208622AC;\n\tTue, 27 Sep 2022 04:37:27 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8CFFB622A6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Sep 2022 04:37:24 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 12326E5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Sep 2022 04:37:24 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664246247;\n\tbh=3AtyT3ZLp2gghWB5SWqTYKKnJHG04bGQ4OdKMiqVpt0=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=pIbst7zX4DMKEkF7G8Usb6dKMGYFY5v+98CR9ASPKhkqk9JNGH2yn3C8SisJvhAuS\n\tZqAMudR0NObB4Lq88nSBtgWYjFCN+YxCb579UGpYHHw2gTkJt0VE0p/kCb9dwHiF5S\n\tssq+lo7mmvOMV/zCZa0OoFOXgCDcnDBEXtPsTJx48TXI2fhttWMd0iB+BZJ8E1mlrb\n\trbWipi6JVPtKGVCVfPTKPS+wVuL6yZgkwD9FFuDDtvPYytouPsdCyAnBi688TOzv5I\n\tNS2XhpaC+0FZlqdlJZ/kYfVgmBAOS4gHkuI+SealOGUmCliKiXKhr++0LSapO184lB\n\tPCAtpu5+EX/2g==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1664246244;\n\tbh=3AtyT3ZLp2gghWB5SWqTYKKnJHG04bGQ4OdKMiqVpt0=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=m9zaWpVFqkVG42IO66MBtrB1Ej8I70Oo1h67RwxY6YhVIrFm9VRWSeTg8ZEQrz0zn\n\t6JifCRAQo4LuaS7LmwI8tkeWWmGvVLAl5NJFzavBtQfSbIVdnmTc8Qa4lOHglTQVOq\n\tJTjfWMKdk2v9bL6CTBvuEEHmjzUorDdjQSkk93O0="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"m9zaWpVF\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 27 Sep 2022 05:36:26 +0300","Message-Id":"<20220927023642.12341-18-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220927023642.12341-1-laurent.pinchart@ideasonboard.com>","References":"<20220927023642.12341-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 17/33] ipa: libipa: Pass FCQueue size\n\tas template argument","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The frame context queue size is meant to be a compile-time constant, not\na variable that can change between runs. Pass it to the class as a\ntemplate argument.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/ipu3/ipa_context.h   |  5 ++++-\n src/ipa/ipu3/ipu3.cpp        |  5 +----\n src/ipa/libipa/fc_queue.cpp  |  6 +++---\n src/ipa/libipa/fc_queue.h    | 17 ++++++++---------\n src/ipa/rkisp1/ipa_context.h |  4 +++-\n src/ipa/rkisp1/rkisp1.cpp    |  4 +---\n 6 files changed, 20 insertions(+), 21 deletions(-)","diff":"diff --git a/src/ipa/ipu3/ipa_context.h b/src/ipa/ipu3/ipa_context.h\nindex 36099353e9f2..bdba3d07d13a 100644\n--- a/src/ipa/ipu3/ipa_context.h\n+++ b/src/ipa/ipu3/ipa_context.h\n@@ -79,11 +79,14 @@ struct IPAFrameContext : public FrameContext {\n \t} sensor;\n };\n \n+/* Maximum number of frame contexts to be held */\n+static constexpr uint32_t kMaxFrameContexts = 16;\n+\n struct IPAContext {\n \tIPASessionConfiguration configuration;\n \tIPAActiveState activeState;\n \n-\tFCQueue<IPAFrameContext> frameContexts;\n+\tFCQueue<IPAFrameContext, kMaxFrameContexts> frameContexts;\n };\n \n } /* namespace ipa::ipu3 */\ndiff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\nindex d1ea081d595d..f5292a77e4d3 100644\n--- a/src/ipa/ipu3/ipu3.cpp\n+++ b/src/ipa/ipu3/ipu3.cpp\n@@ -55,9 +55,6 @@ static constexpr uint32_t kMinCellSizeLog2 = 3;\n /* log2 of the maximum grid cell width and height, in pixels */\n static constexpr uint32_t kMaxCellSizeLog2 = 6;\n \n-/* Maximum number of frame contexts to be held */\n-static constexpr uint32_t kMaxFrameContexts = 16;\n-\n namespace libcamera {\n \n LOG_DEFINE_CATEGORY(IPAIPU3)\n@@ -191,7 +188,7 @@ private:\n };\n \n IPAIPU3::IPAIPU3()\n-\t: context_({ {}, {}, { kMaxFrameContexts } })\n+\t: context_({ {}, {}, {} })\n {\n }\n \ndiff --git a/src/ipa/libipa/fc_queue.cpp b/src/ipa/libipa/fc_queue.cpp\nindex e812faa505a5..9b5702ec5eb0 100644\n--- a/src/ipa/libipa/fc_queue.cpp\n+++ b/src/ipa/libipa/fc_queue.cpp\n@@ -42,6 +42,7 @@ namespace ipa {\n  * \\class FCQueue\n  * \\brief A support class for managing FrameContext instances in IPA modules\n  * \\tparam FrameContext The IPA module-specific FrameContext derived class type\n+ * \\tparam Size The number of contexts in the queue\n  *\n  * Along with the Module and Algorithm classes, the frame context queue is a\n  * core component of the libipa infrastructure. It stores per-frame contexts\n@@ -90,9 +91,8 @@ namespace ipa {\n  */\n \n /**\n- * \\fn FCQueue::FCQueue(unsigned int size)\n- * \\brief Construct a frame contexts queue of a specified size\n- * \\param[in] size The number of contexts in the queue\n+ * \\fn FCQueue::FCQueue()\n+ * \\brief Construct a frame contexts queue\n  */\n \n /**\ndiff --git a/src/ipa/libipa/fc_queue.h b/src/ipa/libipa/fc_queue.h\nindex a589e7e1031b..b9c8c6fe5a62 100644\n--- a/src/ipa/libipa/fc_queue.h\n+++ b/src/ipa/libipa/fc_queue.h\n@@ -7,8 +7,8 @@\n \n #pragma once\n \n+#include <array>\n #include <stdint.h>\n-#include <vector>\n \n #include <libcamera/base/log.h>\n \n@@ -18,21 +18,20 @@ LOG_DECLARE_CATEGORY(FCQueue)\n \n namespace ipa {\n \n-template<typename FrameContext>\n+template<typename FrameContext, std::size_t Size>\n class FCQueue;\n \n struct FrameContext {\n private:\n-\ttemplate<typename T> friend class FCQueue;\n+\ttemplate<typename T, std::size_t> friend class FCQueue;\n \tuint32_t frame;\n };\n \n-template<typename FrameContext>\n+template<typename FrameContext, std::size_t Size>\n class FCQueue\n {\n public:\n-\tFCQueue(unsigned int size)\n-\t\t: contexts_(size)\n+\tFCQueue()\n \t{\n \t}\n \n@@ -44,7 +43,7 @@ public:\n \n \tFrameContext &alloc(const uint32_t frame)\n \t{\n-\t\tFrameContext &frameContext = contexts_[frame % contexts_.size()];\n+\t\tFrameContext &frameContext = contexts_[frame % Size];\n \n \t\t/*\n \t\t * Do not re-initialise if a get() call has already fetched this\n@@ -68,7 +67,7 @@ public:\n \n \tFrameContext &get(uint32_t frame)\n \t{\n-\t\tFrameContext &frameContext = contexts_[frame % contexts_.size()];\n+\t\tFrameContext &frameContext = contexts_[frame % Size];\n \n \t\t/*\n \t\t * If the IPA algorithms try to access a frame context slot which\n@@ -110,7 +109,7 @@ private:\n \t\tframeContext.frame = frame;\n \t}\n \n-\tstd::vector<FrameContext> contexts_;\n+\tstd::array<FrameContext, Size> contexts_;\n };\n \n } /* namespace ipa */\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex f6aaefffed52..4481bd2acde6 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -94,11 +94,13 @@ struct IPAActiveState {\n struct IPAFrameContext : public FrameContext {\n };\n \n+static constexpr uint32_t kMaxFrameContexts = 16;\n+\n struct IPAContext {\n \tIPASessionConfiguration configuration;\n \tIPAActiveState activeState;\n \n-\tFCQueue<IPAFrameContext> frameContexts;\n+\tFCQueue<IPAFrameContext, kMaxFrameContexts> frameContexts;\n };\n \n } /* namespace ipa::rkisp1 */\ndiff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex eb3481949897..b7c1ecfee4c8 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -41,8 +41,6 @@ using namespace std::literals::chrono_literals;\n namespace ipa::rkisp1 {\n \n /* Maximum number of frame contexts to be held */\n-static constexpr uint32_t kMaxFrameContexts = 16;\n-\n class IPARkISP1 : public IPARkISP1Interface, public Module\n {\n public:\n@@ -106,7 +104,7 @@ const ControlInfoMap::Map rkisp1Controls{\n } /* namespace */\n \n IPARkISP1::IPARkISP1()\n-\t: context_({ {}, {}, { kMaxFrameContexts } })\n+\t: context_({ {}, {}, {} })\n {\n }\n \n","prefixes":["libcamera-devel","v5","17/33"]}