[{"id":29094,"web_url":"https://patchwork.libcamera.org/comment/29094/","msgid":"<20240327155442.ieex2kdi74v7repl@jasper>","date":"2024-03-27T15:54:42","subject":"Re: [PATCH 08/10] ipa: rkisp1: Add parseStatistics() to Agc","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Daniel,\n\nthanks for the patch.\n\nOn Fri, Mar 22, 2024 at 01:14:49PM +0000, Daniel Scally wrote:\n> In preparation for switching the RkISP1 Agc to a derivation of\n> MeanLuminanceAgc, add a function that parses the statistics and\n> stores the values for easy retrieval later.\n> \n> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/agc.cpp | 10 ++++++++++\n>  src/ipa/rkisp1/algorithms/agc.h   |  7 +++++++\n>  2 files changed, 17 insertions(+)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> index 47a6f7b2..d380194d 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> @@ -373,6 +373,16 @@ void Agc::fillMetadata(IPAContext &context, IPAFrameContext &frameContext,\n>  \tmetadata.set(controls::FrameDuration, frameDuration.get<std::micro>());\n>  }\n>  \n> +void Agc::parseStatistics(const rkisp1_stat_buffer *stats,\n> +\t\t\t  IPAContext &context)\n> +{\n> +\tconst rkisp1_cif_isp_stat *params = &stats->params;\n> +\n> +\texpMeans_ = { params->ae.exp_mean, context.hw->numAeCells };\n> +\thist_ = Histogram(Span<const uint32_t>(params->hist.hist_bins,\n> +\t\t\t\t\t       context.hw->numHistogramBins));\n\nAs noted in irc, hist_ is only used inside process(). It could be\nreturned from the function. The problem is, that you still need the\nexpMeans_ member, as you can't forward that info into the\nestimateLuminance function. It feels strange, to store references to\nstats->params->ae inside expMeans_ which might be invalid after leaving\nprocess(). Maybe return both (hist and expMeans) from this function and\nonly temporarily assign them to a member inside process()?\n\nCheers,\nStefan\n\n> +}\n> +\n>  /**\n>   * \\brief Process RkISP1 statistics, and run AGC operations\n>   * \\param[in] context The shared IPA context\n> diff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h\n> index fb82a33f..b0de4898 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.h\n> +++ b/src/ipa/rkisp1/algorithms/agc.h\n> @@ -14,6 +14,8 @@\n>  \n>  #include <libcamera/geometry.h>\n>  \n> +#include \"libipa/histogram.h\"\n> +\n>  #include \"algorithm.h\"\n>  \n>  namespace libcamera {\n> @@ -47,10 +49,15 @@ private:\n>  \tdouble measureBrightness(Span<const uint32_t> hist) const;\n>  \tvoid fillMetadata(IPAContext &context, IPAFrameContext &frameContext,\n>  \t\t\t  ControlList &metadata);\n> +\tvoid parseStatistics(const rkisp1_stat_buffer *stats,\n> +\t\t\t     IPAContext &context);\n>  \n>  \tuint64_t frameCount_;\n>  \n>  \tutils::Duration filteredExposure_;\n> +\n> +\tHistogram hist_;\n> +\tSpan<const uint8_t> expMeans_;\n>  };\n>  \n>  } /* namespace ipa::rkisp1::algorithms */\n> -- \n> 2.34.1\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 4EF2BC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 Mar 2024 15:54:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7117063331;\n\tWed, 27 Mar 2024 16:54:47 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 737DB61C35\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Mar 2024 16:54:45 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:da09:7e54:ae7f:d731])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EE8531571;\n\tWed, 27 Mar 2024 16:54:12 +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=\"wj63wSob\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1711554853;\n\tbh=0bwYAI4hZ88ib9FK8qjJMYM+9xwiV3CeA17Vgp5l3WE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=wj63wSobjtn1oZTiKFrhYYVYo7cYBaYWrZOHTXo1iHzB2IN+6fbrC2Te1JGYz9GFf\n\t661Qw3EqPzy5pG6JtRvQJRHO/MSotguqvynxpj5T0mr0olIi+GrM+7/ziJs1HR8Z9M\n\tFBnzl6pDloCezd8aukvopq/BLMKtwf2E26L3uuGg=","Date":"Wed, 27 Mar 2024 16:54:42 +0100","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Daniel Scally <dan.scally@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 08/10] ipa: rkisp1: Add parseStatistics() to Agc","Message-ID":"<20240327155442.ieex2kdi74v7repl@jasper>","References":"<20240322131451.3092931-1-dan.scally@ideasonboard.com>\n\t<20240322131451.3092931-9-dan.scally@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240322131451.3092931-9-dan.scally@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>"}},{"id":29171,"web_url":"https://patchwork.libcamera.org/comment/29171/","msgid":"<20240406014141.GO12507@pendragon.ideasonboard.com>","date":"2024-04-06T01:41:41","subject":"Re: [PATCH 08/10] ipa: rkisp1: Add parseStatistics() to Agc","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Dan,\n\nThank you for the patch.\n\nOn Fri, Mar 22, 2024 at 01:14:49PM +0000, Daniel Scally wrote:\n> In preparation for switching the RkISP1 Agc to a derivation of\n> MeanLuminanceAgc, add a function that parses the statistics and\n> stores the values for easy retrieval later.\n> \n> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n\nAs commented on 05/10, squash this with 09/10 as it's more difficult to\nreview in isolation.\n\n> ---\n>  src/ipa/rkisp1/algorithms/agc.cpp | 10 ++++++++++\n>  src/ipa/rkisp1/algorithms/agc.h   |  7 +++++++\n>  2 files changed, 17 insertions(+)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/agc.cpp b/src/ipa/rkisp1/algorithms/agc.cpp\n> index 47a6f7b2..d380194d 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.cpp\n> +++ b/src/ipa/rkisp1/algorithms/agc.cpp\n> @@ -373,6 +373,16 @@ void Agc::fillMetadata(IPAContext &context, IPAFrameContext &frameContext,\n>  \tmetadata.set(controls::FrameDuration, frameDuration.get<std::micro>());\n>  }\n>  \n> +void Agc::parseStatistics(const rkisp1_stat_buffer *stats,\n> +\t\t\t  IPAContext &context)\n> +{\n> +\tconst rkisp1_cif_isp_stat *params = &stats->params;\n> +\n> +\texpMeans_ = { params->ae.exp_mean, context.hw->numAeCells };\n> +\thist_ = Histogram(Span<const uint32_t>(params->hist.hist_bins,\n> +\t\t\t\t\t       context.hw->numHistogramBins));\n> +}\n> +\n>  /**\n>   * \\brief Process RkISP1 statistics, and run AGC operations\n>   * \\param[in] context The shared IPA context\n> diff --git a/src/ipa/rkisp1/algorithms/agc.h b/src/ipa/rkisp1/algorithms/agc.h\n> index fb82a33f..b0de4898 100644\n> --- a/src/ipa/rkisp1/algorithms/agc.h\n> +++ b/src/ipa/rkisp1/algorithms/agc.h\n> @@ -14,6 +14,8 @@\n>  \n>  #include <libcamera/geometry.h>\n>  \n> +#include \"libipa/histogram.h\"\n> +\n>  #include \"algorithm.h\"\n>  \n>  namespace libcamera {\n> @@ -47,10 +49,15 @@ private:\n>  \tdouble measureBrightness(Span<const uint32_t> hist) const;\n>  \tvoid fillMetadata(IPAContext &context, IPAFrameContext &frameContext,\n>  \t\t\t  ControlList &metadata);\n> +\tvoid parseStatistics(const rkisp1_stat_buffer *stats,\n> +\t\t\t     IPAContext &context);\n>  \n>  \tuint64_t frameCount_;\n>  \n>  \tutils::Duration filteredExposure_;\n> +\n> +\tHistogram hist_;\n> +\tSpan<const uint8_t> expMeans_;\n>  };\n>  \n>  } /* namespace ipa::rkisp1::algorithms */","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 50595C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  6 Apr 2024 01:41:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9887463340;\n\tSat,  6 Apr 2024 03:41:54 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F49761C15\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  6 Apr 2024 03:41:52 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2EDE8231;\n\tSat,  6 Apr 2024 03:41:13 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"F0V4Pi0w\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1712367673;\n\tbh=MR/oZnn8ZkedQGfKk0fnLhZmFcl+GBBOTInw0JRiz8Q=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=F0V4Pi0wr2S2a0Mz96+N3yNqD6tUMmFYCKz4mYR/BWM+iYq65KWGdrcmGGsHWruB1\n\tJ3L2UUTI+4nTVTKCZmLno67m4/0GyT9GsLb+gojGzxz6PKOVwUX7tEEH1xG+OAJIyS\n\tE+cy8lofa1Vf0jw0DAqvHdIN0A8CiqXD4EiaDagk=","Date":"Sat, 6 Apr 2024 04:41:41 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Daniel Scally <dan.scally@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 08/10] ipa: rkisp1: Add parseStatistics() to Agc","Message-ID":"<20240406014141.GO12507@pendragon.ideasonboard.com>","References":"<20240322131451.3092931-1-dan.scally@ideasonboard.com>\n\t<20240322131451.3092931-9-dan.scally@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240322131451.3092931-9-dan.scally@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>"}}]