{"id":17332,"url":"https://patchwork.libcamera.org/api/patches/17332/?format=json","web_url":"https://patchwork.libcamera.org/patch/17332/","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":"<20220908014200.28728-24-laurent.pinchart@ideasonboard.com>","date":"2022-09-08T01:41:51","name":"[libcamera-devel,v4,23/32] ipa: rkisp1: filter: Store per-frame information in frame context","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"065c89a0a1619fea57215a276c1dafac5aa31bd8","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/17332/mbox/","series":[{"id":3476,"url":"https://patchwork.libcamera.org/api/series/3476/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3476","date":"2022-09-08T01:41:28","name":"ipa: Frame context queue, IPU3 & RkISP consolidation, and RkISP1 improvements","version":4,"mbox":"https://patchwork.libcamera.org/series/3476/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17332/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17332/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 A5CCDC327D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  8 Sep 2022 01:42:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 67006620EB;\n\tThu,  8 Sep 2022 03:42:52 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 24DA1620E1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Sep 2022 03:42:50 +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 A456C8F1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  8 Sep 2022 03:42:49 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1662601372;\n\tbh=9ZhAZnf6lr0krKmTVy/pD4FI0CBNPWwai1Lq3wgarBE=;\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=B211SLpB/WgiFuD6rfZL1Kh3LQSCsiItxfxPvjtuHzmCSs0DZv3x/Tg/NfT+E7ogP\n\tWlsIuixj7UtE8359lgqTJYxyo+Ga1T0IU78QWoJyRY9dZVKrBOVRJWMPZCS/zvuL/Z\n\thPdyvtbhZUROFemX2vv6jGN35q94KjSkgTitHWN4AO6ayBMF3oNR/axw7dUQXG0Wzu\n\tpZtsv2ByJG1a0y8KWQPSy2Tq1yRUeOFANgYiTj0oE6pqXGpL9sHLZuXVdD20SPqL3Y\n\tTMhJ79JBnD1YKm0+CZ8QyJiGyrgVTriSz9+AiXVOC8OxkebPY39PBfJ4Qg8+1PAtnD\n\tU84qtgk8hNLzw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1662601369;\n\tbh=9ZhAZnf6lr0krKmTVy/pD4FI0CBNPWwai1Lq3wgarBE=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=nMfWpzuzHhaf9kIosHbXyI2ZwnIMpZxgQ6GbTTZC0IYNtnLY5PWOY2cBRUGLMrdVG\n\tu9FWFcnbXy3I/kvhKZuQ9SAila+SrzveYeMGOsxLGpoWqqpK2AccCt1hDA2eyZ8CjP\n\t+5BivHjY3qV7akuKsj3Nm7thas4LUCuhygRHQnhI="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"nMfWpzuz\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  8 Sep 2022 04:41:51 +0300","Message-Id":"<20220908014200.28728-24-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220908014200.28728-1-laurent.pinchart@ideasonboard.com>","References":"<20220908014200.28728-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 23/32] ipa: rkisp1: filter: Store\n\tper-frame information in frame context","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":"Rework the algorithm's usage of the active state, to store the value of\ncontrols for the last queued request in the queueRequest() function, and\nstore a copy of the values in the corresponding frame context. The\nlatter is used in the prepare() function to populate the ISP parameters\nwith values corresponding to the right frame.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/rkisp1/algorithms/filter.cpp | 30 +++++++++++++++-------------\n src/ipa/rkisp1/ipa_context.cpp       | 18 ++++++++++++++---\n src/ipa/rkisp1/ipa_context.h         |  7 ++++++-\n 3 files changed, 37 insertions(+), 18 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/filter.cpp b/src/ipa/rkisp1/algorithms/filter.cpp\nindex e64bd6a6d68f..ac743729e247 100644\n--- a/src/ipa/rkisp1/algorithms/filter.cpp\n+++ b/src/ipa/rkisp1/algorithms/filter.cpp\n@@ -44,15 +44,16 @@ static constexpr uint32_t kFiltModeDefault = 0x000004f2;\n  */\n void Filter::queueRequest(IPAContext &context,\n \t\t\t  [[maybe_unused]] const uint32_t frame,\n-\t\t\t  [[maybe_unused]] RkISP1FrameContext &frameContext,\n+\t\t\t  RkISP1FrameContext &frameContext,\n \t\t\t  const ControlList &controls)\n {\n \tauto &filter = context.activeState.filter;\n+\tbool update = false;\n \n \tconst auto &sharpness = controls.get(controls::Sharpness);\n \tif (sharpness) {\n \t\tfilter.sharpness = std::round(std::clamp(*sharpness, 0.0f, 10.0f));\n-\t\tfilter.updateParams = true;\n+\t\tupdate = true;\n \n \t\tLOG(RkISP1Filter, Debug) << \"Set sharpness to \" << *sharpness;\n \t}\n@@ -64,41 +65,42 @@ void Filter::queueRequest(IPAContext &context,\n \t\tswitch (*denoise) {\n \t\tcase controls::draft::NoiseReductionModeOff:\n \t\t\tfilter.denoise = 0;\n-\t\t\tfilter.updateParams = true;\n+\t\t\tupdate = true;\n \t\t\tbreak;\n \t\tcase controls::draft::NoiseReductionModeMinimal:\n \t\t\tfilter.denoise = 1;\n-\t\t\tfilter.updateParams = true;\n+\t\t\tupdate = true;\n \t\t\tbreak;\n \t\tcase controls::draft::NoiseReductionModeHighQuality:\n \t\tcase controls::draft::NoiseReductionModeFast:\n \t\t\tfilter.denoise = 3;\n-\t\t\tfilter.updateParams = true;\n+\t\t\tupdate = true;\n \t\t\tbreak;\n \t\tdefault:\n \t\t\tLOG(RkISP1Filter, Error)\n \t\t\t\t<< \"Unsupported denoise value \"\n \t\t\t\t<< *denoise;\n+\t\t\tbreak;\n \t\t}\n \t}\n+\n+\tframeContext.filter.denoise = filter.denoise;\n+\tframeContext.filter.sharpness = filter.sharpness;\n+\tframeContext.filter.update = update;\n }\n \n /**\n  * \\copydoc libcamera::ipa::Algorithm::prepare\n  */\n-void Filter::prepare(IPAContext &context,\n+void Filter::prepare([[maybe_unused]] IPAContext &context,\n \t\t     [[maybe_unused]] const uint32_t frame,\n-\t\t     [[maybe_unused]] RkISP1FrameContext &frameContext,\n+\t\t     RkISP1FrameContext &frameContext,\n \t\t     rkisp1_params_cfg *params)\n {\n-\tauto &filter = context.activeState.filter;\n-\n \t/* Check if the algorithm configuration has been updated. */\n-\tif (!filter.updateParams)\n+\tif (!frameContext.filter.update)\n \t\treturn;\n \n-\tfilter.updateParams = false;\n-\n \tstatic constexpr uint16_t filt_fac_sh0[] = {\n \t\t0x04, 0x07, 0x0a, 0x0c, 0x10, 0x14, 0x1a, 0x1e, 0x24, 0x2a, 0x30\n \t};\n@@ -147,8 +149,8 @@ void Filter::prepare(IPAContext &context,\n \t\t0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3\n \t};\n \n-\tuint8_t denoise = filter.denoise;\n-\tuint8_t sharpness = filter.sharpness;\n+\tuint8_t denoise = frameContext.filter.denoise;\n+\tuint8_t sharpness = frameContext.filter.sharpness;\n \tauto &flt_config = params->others.flt_config;\n \n \tflt_config.fac_sh0 = filt_fac_sh0[sharpness];\ndiff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\nindex b0210a978559..b2628ef73d49 100644\n--- a/src/ipa/rkisp1/ipa_context.cpp\n+++ b/src/ipa/rkisp1/ipa_context.cpp\n@@ -179,9 +179,6 @@ namespace libcamera::ipa::rkisp1 {\n  *\n  * \\var IPAActiveState::filter.sharpness\n  * \\brief Sharpness level\n- *\n- * \\var IPAActiveState::filter.updateParams\n- * \\brief Indicates if ISP parameters need to be updated\n  */\n \n /**\n@@ -260,6 +257,21 @@ namespace libcamera::ipa::rkisp1 {\n  * compared to the previous frame\n  */\n \n+/**\n+ * \\var RkISP1FrameContext::filter\n+ * \\brief Filter parameters for this frame\n+ *\n+ * \\struct RkISP1FrameContext::filter.denoise\n+ * \\brief Denoising level\n+ *\n+ * \\var RkISP1FrameContext::filter.sharpness\n+ * \\brief Sharpness level\n+ *\n+ * \\var RkISP1FrameContext::filter.updateParams\n+ * \\brief Indicates if the filter parameters have been updated compared to the\n+ * previous frame\n+ */\n+\n /**\n  * \\var RkISP1FrameContext::sensor\n  * \\brief Sensor configuration that used been used for this frame\ndiff --git a/src/ipa/rkisp1/ipa_context.h b/src/ipa/rkisp1/ipa_context.h\nindex c22e1f099c23..c15b908afcc8 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -84,7 +84,6 @@ struct IPAActiveState {\n \tstruct {\n \t\tuint8_t denoise;\n \t\tuint8_t sharpness;\n-\t\tbool updateParams;\n \t} filter;\n };\n \n@@ -117,6 +116,12 @@ struct RkISP1FrameContext : public FrameContext {\n \t\tbool update;\n \t} dpf;\n \n+\tstruct {\n+\t\tuint8_t denoise;\n+\t\tuint8_t sharpness;\n+\t\tbool update;\n+\t} filter;\n+\n \tstruct {\n \t\tuint32_t exposure;\n \t\tdouble gain;\n","prefixes":["libcamera-devel","v4","23/32"]}