[{"id":37410,"web_url":"https://patchwork.libcamera.org/comment/37410/","msgid":"<o57clp6zwth4doefhie6bn7ib3mcdp6rlezngcv5dvzmuztwvg@3upr6nmdr2vv>","date":"2025-12-16T16:50:44","subject":"Re: [PATCH v5 1/6] ipa: rkisp1: algorithms: dpf: refactor DPF\n\tparsing and initialization","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"Hi Rui\n\nOn Sun, Dec 14, 2025 at 01:16:41PM -0500, Rui Wang wrote:\n> Split DPF configuration parsing and initialization into clearer,\n> self-contained helpers and modernized initialization patterns.\n>\n> Introduce parseSingleConfig() as DPF tuning file parser helper\n> make future extensions and maintenance easier.\n>\n> Change strengthconfig.r/g/b parser from uint16 to uint8\n> to match rkisp1_cif_isp_dpf_strength_config defination.\n\nAs commented in the previous version\ns/defination/definition\n\n>\n> Signed-off-by: Rui Wang <rui.wang@ideasonboard.com>\n\nWhen you receive a tag on a patch, like the one I gave on the previous\nversion, you should collect it and paste it here. It's a tedious and\nmanual process, but that's what we have at the moment...\n\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n   j\n\n> ---\n>\n> changelog:\n>  - propagates specific integer error codes (e.g. -EINVAL) from\n>  parseConfig and  parseSingleConfig instead of\n>  returning boolean false values, improving error reporting.\n>  - format the code : Unbraced if (single-statement if)\n>\n>  src/ipa/rkisp1/algorithms/dpf.cpp | 52 ++++++++++++++++++++++---------\n>  src/ipa/rkisp1/algorithms/dpf.h   |  5 +++\n>  2 files changed, 42 insertions(+), 15 deletions(-)\n>\n> diff --git a/src/ipa/rkisp1/algorithms/dpf.cpp b/src/ipa/rkisp1/algorithms/dpf.cpp\n> index 39f3e461..dd3effa1 100644\n> --- a/src/ipa/rkisp1/algorithms/dpf.cpp\n> +++ b/src/ipa/rkisp1/algorithms/dpf.cpp\n> @@ -46,6 +46,28 @@ Dpf::Dpf()\n>   */\n>  int Dpf::init([[maybe_unused]] IPAContext &context,\n>  \t      const YamlObject &tuningData)\n> +{\n> +\t/* Parse tuning block. */\n> +\tint ret = parseConfig(tuningData);\n> +\tif (ret)\n> +\t\treturn ret;\n> +\n> +\treturn 0;\n> +}\n> +\n> +int Dpf::parseConfig(const YamlObject &tuningData)\n> +{\n> +\t/* Parse base config. */\n> +\tint ret = parseSingleConfig(tuningData, config_, strengthConfig_);\n> +\tif (ret)\n> +\t\treturn ret;\n> +\n> +\treturn 0;\n> +}\n> +\n> +int 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> @@ -82,10 +104,10 @@ int Dpf::init([[maybe_unused]] IPAContext &context,\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> @@ -119,15 +141,15 @@ int Dpf::init([[maybe_unused]] IPAContext &context,\n>  \t\treturn -EINVAL;\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> @@ -147,13 +169,13 @@ int Dpf::init([[maybe_unused]] IPAContext &context,\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> @@ -164,9 +186,9 @@ int Dpf::init([[maybe_unused]] IPAContext &context,\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>  }\n> diff --git a/src/ipa/rkisp1/algorithms/dpf.h b/src/ipa/rkisp1/algorithms/dpf.h\n> index 2dd8cd36..39186c55 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> +\tint parseConfig(const YamlObject &tuningData);\n> +\tint 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> --\n> 2.43.0\n>","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 F0FABBD7D8\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Dec 2025 16:50:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0458F61A2C;\n\tTue, 16 Dec 2025 17:50:50 +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 A02E16191D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Dec 2025 17:50:47 +0100 (CET)","from ideasonboard.com (93-46-82-201.ip106.fastwebnet.it\n\t[93.46.82.201])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E14B8D6;\n\tTue, 16 Dec 2025 17:50:41 +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=\"an/E2PH1\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1765903842;\n\tbh=M0EMYTfP3+4mbSgFHj7G/3wnk4KMhCUMuLtl+21OI7A=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=an/E2PH1uYMAKaka0PBinCud3iWolYCGtmCQjHYcATuhelavZ3Z1PK+SiK/C7rbKS\n\tWekZgmifdH0Inbgi8gPTBu2W4SBiEen6Vnejf6k8MPCp2ybU8vqHs6MMHxBxTvl86h\n\t3GksgvHVLvkcBlTJQzuxL5DQSIo2TJ73ImNtA9Ys=","Date":"Tue, 16 Dec 2025 17:50:44 +0100","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","To":"Rui Wang <rui.wang@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v5 1/6] ipa: rkisp1: algorithms: dpf: refactor DPF\n\tparsing and initialization","Message-ID":"<o57clp6zwth4doefhie6bn7ib3mcdp6rlezngcv5dvzmuztwvg@3upr6nmdr2vv>","References":"<20251214181646.573675-1-rui.wang@ideasonboard.com>\n\t<20251214181646.573675-2-rui.wang@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20251214181646.573675-2-rui.wang@ideasonboard.com>","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>"}}]