{"id":17434,"url":"https://patchwork.libcamera.org/api/patches/17434/?format=json","web_url":"https://patchwork.libcamera.org/patch/17434/","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-24-laurent.pinchart@ideasonboard.com>","date":"2022-09-27T02:36:32","name":"[libcamera-devel,v5,23/33] ipa: rkisp1: dpf: Store per-frame information in frame context","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"24b158118424636cb051607160927ecbaa4a14a4","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/17434/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/17434/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17434/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 9816DC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Sep 2022 02:37:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 52574622B6;\n\tTue, 27 Sep 2022 04:37:38 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 51A3B61F79\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Sep 2022 04:37:36 +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 7462FE5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Sep 2022 04:37:35 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1664246258;\n\tbh=fM0v5GdYx5Qzd+oE/S32nz8rJN8nsoZ4NM3CXVXGwrQ=;\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=IacQ7ENzYBxzWPBV91hKiCPOtmSm8LME/zCVOW8Rs5mXv7Om4CZyEzwfz32qgMz/s\n\tOhJXqq1mY3T/je4PsUHDfSWdb0ahG0Th9c7L4QR7RtLRcxPoPO9gpJnt1uRQN/m09L\n\tkMB/EKz/+A6WhYw3L7MbavKM4ZNBc4RmHsLcWBhKyKwbL71Ecj6xSFrv5yjhcfC0re\n\tztDYn2kzdNiyNYxQSZxIcG44/ZiiroLitzTazMRqopXQB3FYrApQVHC2Jk/lhYpARY\n\toFPWcUVFoDlzEYZg01kCt6mVb4xfifcKWg+xT4VnbOdziKroVqPXeD9EOH8HZZb/am\n\tPrdSVXXbW/D5A==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1664246256;\n\tbh=fM0v5GdYx5Qzd+oE/S32nz8rJN8nsoZ4NM3CXVXGwrQ=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=BcMLDe2VYNdLrnw7EzVuzCn5UecXl9wBZy4ROmjrjdFo/WU12MJsqe5zlIPP/o4Rk\n\tDy+jWTy7bbyN9pLpMYLqfNq3f0y0iQCYmBxz79Ygh2SUKerKAb1ahjxI7ladLml9aS\n\t5nUR0vwsoTw7jnE1sA7mhW9X+9Q2S0C7N1OjYc6s="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"BcMLDe2V\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 27 Sep 2022 05:36:32 +0300","Message-Id":"<20220927023642.12341-24-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 23/33] ipa: rkisp1: dpf: 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>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\nChanges since v4:\n\n- Only update parameters when values have changed\n---\n src/ipa/rkisp1/algorithms/dpf.cpp | 30 +++++++++++++++++-------------\n src/ipa/rkisp1/ipa_context.cpp    | 15 ++++++++++++---\n src/ipa/rkisp1/ipa_context.h      |  6 +++++-\n 3 files changed, 34 insertions(+), 17 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp\nindex b8d0c7b85639..f7bc371da52e 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.cpp\n+++ b/src/ipa/rkisp1/algorithms/dpf.cpp\n@@ -176,10 +176,11 @@ int Dpf::init([[maybe_unused]] IPAContext &context,\n  */\n void Dpf::queueRequest(IPAContext &context,\n \t\t       [[maybe_unused]] const uint32_t frame,\n-\t\t       [[maybe_unused]] IPAFrameContext &frameContext,\n+\t\t       IPAFrameContext &frameContext,\n \t\t       const ControlList &controls)\n {\n \tauto &dpf = context.activeState.dpf;\n+\tbool update = false;\n \n \tconst auto &denoise = controls.get(controls::draft::NoiseReductionMode);\n \tif (denoise) {\n@@ -187,35 +188,40 @@ void Dpf::queueRequest(IPAContext &context,\n \n \t\tswitch (*denoise) {\n \t\tcase controls::draft::NoiseReductionModeOff:\n-\t\t\tdpf.denoise = false;\n-\t\t\tdpf.updateParams = true;\n+\t\t\tif (dpf.denoise) {\n+\t\t\t\tdpf.denoise = false;\n+\t\t\t\tupdate = true;\n+\t\t\t}\n \t\t\tbreak;\n \t\tcase controls::draft::NoiseReductionModeMinimal:\n \t\tcase controls::draft::NoiseReductionModeHighQuality:\n \t\tcase controls::draft::NoiseReductionModeFast:\n-\t\t\tdpf.denoise = true;\n-\t\t\tdpf.updateParams = true;\n+\t\t\tif (!dpf.denoise) {\n+\t\t\t\tdpf.denoise = true;\n+\t\t\t\tupdate = true;\n+\t\t\t}\n \t\t\tbreak;\n \t\tdefault:\n \t\t\tLOG(RkISP1Dpf, 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.dpf.denoise = dpf.denoise;\n+\tframeContext.dpf.update = update;\n }\n \n /**\n  * \\copydoc libcamera::ipa::Algorithm::prepare\n  */\n void Dpf::prepare(IPAContext &context, const uint32_t frame,\n-\t\t  [[maybe_unused]] IPAFrameContext &frameContext,\n-\t\t  rkisp1_params_cfg *params)\n+\t\t  IPAFrameContext &frameContext, rkisp1_params_cfg *params)\n {\n \tif (!initialized_)\n \t\treturn;\n \n-\tauto &dpf = context.activeState.dpf;\n-\n \tif (frame == 0) {\n \t\tparams->others.dpf_config = config_;\n \t\tparams->others.dpf_strength_config = strengthConfig_;\n@@ -245,12 +251,10 @@ void Dpf::prepare(IPAContext &context, const uint32_t frame,\n \t\t\t\t\t     RKISP1_CIF_ISP_MODULE_DPF_STRENGTH;\n \t}\n \n-\tif (dpf.updateParams) {\n+\tif (frameContext.dpf.update) {\n \t\tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_DPF;\n-\t\tif (dpf.denoise)\n+\t\tif (frameContext.dpf.denoise)\n \t\t\tparams->module_ens |= RKISP1_CIF_ISP_MODULE_DPF;\n-\n-\t\tdpf.updateParams = false;\n \t}\n }\n \ndiff --git a/src/ipa/rkisp1/ipa_context.cpp b/src/ipa/rkisp1/ipa_context.cpp\nindex fdc8e7df0b76..c7cd007b2428 100644\n--- a/src/ipa/rkisp1/ipa_context.cpp\n+++ b/src/ipa/rkisp1/ipa_context.cpp\n@@ -168,9 +168,6 @@ namespace libcamera::ipa::rkisp1 {\n  *\n  * \\var IPAActiveState::dpf.denoise\n  * \\brief Indicates if denoise is activated\n- *\n- * \\var IPAActiveState::dpf.updateParams\n- * \\brief Indicates if ISP parameters need to be updated\n  */\n \n /**\n@@ -251,6 +248,18 @@ namespace libcamera::ipa::rkisp1 {\n  * compared to the previous frame\n  */\n \n+/**\n+ * \\var IPAFrameContext::dpf\n+ * \\brief Denoise Pre-Filter parameters for this frame\n+ *\n+ * \\var IPAFrameContext::dpf.denoise\n+ * \\brief Indicates if denoise is activated\n+ *\n+ * \\var IPAFrameContext::dpf.update\n+ * \\brief Indicates if the denoise pre-filter parameters have been updated\n+ * compared to the previous frame\n+ */\n+\n /**\n  * \\var IPAFrameContext::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 cc217aec511a..81b632a15960 100644\n--- a/src/ipa/rkisp1/ipa_context.h\n+++ b/src/ipa/rkisp1/ipa_context.h\n@@ -80,7 +80,6 @@ struct IPAActiveState {\n \n \tstruct {\n \t\tbool denoise;\n-\t\tbool updateParams;\n \t} dpf;\n \n \tstruct {\n@@ -114,6 +113,11 @@ struct IPAFrameContext : public FrameContext {\n \t\tbool update;\n \t} cproc;\n \n+\tstruct {\n+\t\tbool denoise;\n+\t\tbool update;\n+\t} dpf;\n+\n \tstruct {\n \t\tuint32_t exposure;\n \t\tdouble gain;\n","prefixes":["libcamera-devel","v5","23/33"]}