{"id":25379,"url":"https://patchwork.libcamera.org/api/patches/25379/?format=json","web_url":"https://patchwork.libcamera.org/patch/25379/","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":"<20251208004808.1274417-2-rui.wang@ideasonboard.com>","date":"2025-12-08T00:48:02","name":"[v4,1/7] ipa: rkisp1: algorithms: dpf: refactor DPF parsing and initialization","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"608ef83fe7f95091b5b6a04d43be457fff8de779","submitter":{"id":241,"url":"https://patchwork.libcamera.org/api/people/241/?format=json","name":"Rui Wang","email":"rui.wang@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/25379/mbox/","series":[{"id":5641,"url":"https://patchwork.libcamera.org/api/series/5641/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5641","date":"2025-12-08T00:48:01","name":"rebase_dpf_refactory_patch_v4","version":4,"mbox":"https://patchwork.libcamera.org/series/5641/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/25379/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/25379/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 AFCD7C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  8 Dec 2025 00:48:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4D66A613F2;\n\tMon,  8 Dec 2025 01:48:38 +0100 (CET)","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 8709B6069A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  8 Dec 2025 01:48:36 +0100 (CET)","from localhost.localdomain (unknown [209.216.103.65])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 490A21AE2;\n\tMon,  8 Dec 2025 01:46:18 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"s2gWIXWf\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1765154778;\n\tbh=g09nfQfTn00qYQBsIHnV8bB/7fyBUPxzBvnFg955EKA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=s2gWIXWfo8u+WiZgBudzUCqP5GrAaHQbETFzY98xNTaeInvvkX6eujwUjo1fhwFP3\n\tYYCkbMSkknRuBty182am+juxwejGHzKwCFLporXL8/HIpCWS76Trt1FPz85xyJEzmk\n\tnDpo7nOtZfHzfM/I5nS6KxrmWIHTdiBV8tZdtHkE=","From":"Rui Wang <rui.wang@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Rui Wang <rui.wang@ideasonboard.com>","Subject":"[PATCH v4 1/7] ipa: rkisp1: algorithms: dpf: refactor DPF parsing\n\tand initialization","Date":"Sun,  7 Dec 2025 19:48:02 -0500","Message-ID":"<20251208004808.1274417-2-rui.wang@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","In-Reply-To":"<20251208004808.1274417-1-rui.wang@ideasonboard.com>","References":"<20251208004808.1274417-1-rui.wang@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"-Split DPF configuration parsing and initialization into clearer,\nself-contained helpers and modernized initialization patterns.\n\n-Introduce parseSingleConfig() as DPF tuning file parser helper\nmake future extensions and maintenance easier\n\n-Change strengthconfig.r/g/b parser from uint16 to uint8\nto match rkisp1_cif_isp_dpf_strength_config defination\n\nSigned-off-by: Rui Wang <rui.wang@ideasonboard.com>\n---\nChangelog in v4: \n -Split V3 one patch into 6 patches\n -The first patch only focus on code reorgnization, no new logic added\n -Delete Makefile from  V3 patch\n\n src/ipa/rkisp1/algorithms/dpf.cpp | 61 +++++++++++++++++++++----------\n src/ipa/rkisp1/algorithms/dpf.h   |  5 +++\n 2 files changed, 46 insertions(+), 20 deletions(-)","diff":"diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp\nindex 39f3e461..cd0a7d9d 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.cpp\n+++ b/src/ipa/rkisp1/algorithms/dpf.cpp\n@@ -46,6 +46,27 @@ Dpf::Dpf()\n  */\n int Dpf::init([[maybe_unused]] IPAContext &context,\n \t      const YamlObject &tuningData)\n+{\n+\t/* Parse tuning block. */\n+\tif (!parseConfig(tuningData)) {\n+\t\treturn -EINVAL;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+bool Dpf::parseConfig(const YamlObject &tuningData)\n+{\n+\t/* Parse base config. */\n+\tif (!parseSingleConfig(tuningData, config_, strengthConfig_)) {\n+\t\treturn false;\n+\t}\n+\treturn true;\n+}\n+\n+bool Dpf::parseSingleConfig(const YamlObject &tuningData,\n+\t\t\t    rkisp1_cif_isp_dpf_config &config,\n+\t\t\t    rkisp1_cif_isp_dpf_strength_config &strengthConfig)\n {\n \tstd::vector<uint8_t> values;\n \n@@ -78,14 +99,14 @@ int Dpf::init([[maybe_unused]] IPAContext &context,\n \t\t\t<< \"Invalid 'DomainFilter:g': expected \"\n \t\t\t<< RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS\n \t\t\t<< \" elements, got \" << values.size();\n-\t\treturn -EINVAL;\n+\t\treturn false;\n \t}\n \n \tstd::copy_n(values.begin(), values.size(),\n-\t\t    std::begin(config_.g_flt.spatial_coeff));\n+\t\t    std::begin(config.g_flt.spatial_coeff));\n \n-\tconfig_.g_flt.gr_enable = true;\n-\tconfig_.g_flt.gb_enable = true;\n+\tconfig.g_flt.gr_enable = true;\n+\tconfig.g_flt.gb_enable = true;\n \n \t/*\n \t * For the red and blue components, we have the 13x9 kernel specified\n@@ -116,18 +137,18 @@ int Dpf::init([[maybe_unused]] IPAContext &context,\n \t\t\t<< RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS - 1\n \t\t\t<< \" or \" << RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS\n \t\t\t<< \" elements, got \" << values.size();\n-\t\treturn -EINVAL;\n+\t\treturn false;\n \t}\n \n-\tconfig_.rb_flt.fltsize = values.size() == RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS\n-\t\t\t       ? RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9\n-\t\t\t       : RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9;\n+\tconfig.rb_flt.fltsize = values.size() == RKISP1_CIF_ISP_DPF_MAX_SPATIAL_COEFFS\n+\t\t\t\t\t? RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9\n+\t\t\t\t\t: RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9;\n \n \tstd::copy_n(values.begin(), values.size(),\n-\t\t    std::begin(config_.rb_flt.spatial_coeff));\n+\t\t    std::begin(config.rb_flt.spatial_coeff));\n \n-\tconfig_.rb_flt.r_enable = true;\n-\tconfig_.rb_flt.b_enable = true;\n+\tconfig.rb_flt.r_enable = true;\n+\tconfig.rb_flt.b_enable = true;\n \n \t/*\n \t * The range kernel is configured with a noise level lookup table (NLL)\n@@ -143,32 +164,32 @@ int Dpf::init([[maybe_unused]] IPAContext &context,\n \t\t\t<< \"Invalid 'RangeFilter:coeff': expected \"\n \t\t\t<< RKISP1_CIF_ISP_DPF_MAX_NLF_COEFFS\n \t\t\t<< \" elements, got \" << nllValues.size();\n-\t\treturn -EINVAL;\n+\t\treturn false;\n \t}\n \n \tstd::copy_n(nllValues.begin(), nllValues.size(),\n-\t\t    std::begin(config_.nll.coeff));\n+\t\t    std::begin(config.nll.coeff));\n \n \tstd::string scaleMode = rFObject[\"scale-mode\"].get<std::string>(\"\");\n \tif (scaleMode == \"linear\") {\n-\t\tconfig_.nll.scale_mode = RKISP1_CIF_ISP_NLL_SCALE_LINEAR;\n+\t\tconfig.nll.scale_mode = RKISP1_CIF_ISP_NLL_SCALE_LINEAR;\n \t} else if (scaleMode == \"logarithmic\") {\n-\t\tconfig_.nll.scale_mode = RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC;\n+\t\tconfig.nll.scale_mode = RKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC;\n \t} else {\n \t\tLOG(RkISP1Dpf, Error)\n \t\t\t<< \"Invalid 'RangeFilter:scale-mode': expected \"\n \t\t\t<< \"'linear' or 'logarithmic' value, got \"\n \t\t\t<< scaleMode;\n-\t\treturn -EINVAL;\n+\t\treturn false;\n \t}\n \n \tconst YamlObject &fSObject = tuningData[\"FilterStrength\"];\n \n-\tstrengthConfig_.r = fSObject[\"r\"].get<uint16_t>(64);\n-\tstrengthConfig_.g = fSObject[\"g\"].get<uint16_t>(64);\n-\tstrengthConfig_.b = fSObject[\"b\"].get<uint16_t>(64);\n+\tstrengthConfig.r = fSObject[\"r\"].get<uint8_t>().value_or(64);\n+\tstrengthConfig.g = fSObject[\"g\"].get<uint8_t>().value_or(64);\n+\tstrengthConfig.b = fSObject[\"b\"].get<uint8_t>().value_or(64);\n \n-\treturn 0;\n+\treturn true;\n }\n \n /**\ndiff --git a/src/ipa/rkisp1/algorithms/dpf.h b/src/ipa/rkisp1/algorithms/dpf.h\nindex 2dd8cd36..bee6fc9b 100644\n--- a/src/ipa/rkisp1/algorithms/dpf.h\n+++ b/src/ipa/rkisp1/algorithms/dpf.h\n@@ -30,6 +30,11 @@ public:\n \t\t     RkISP1Params *params) override;\n \n private:\n+\tbool parseConfig(const YamlObject &tuningData);\n+\tbool parseSingleConfig(const YamlObject &tuningData,\n+\t\t\t       rkisp1_cif_isp_dpf_config &config,\n+\t\t\t       rkisp1_cif_isp_dpf_strength_config &strengthConfig);\n+\n \tstruct rkisp1_cif_isp_dpf_config config_;\n \tstruct rkisp1_cif_isp_dpf_strength_config strengthConfig_;\n };\n","prefixes":["v4","1/7"]}