[{"id":29068,"web_url":"https://patchwork.libcamera.org/comment/29068/","msgid":"<20240326110354.ul2mwfju6746tjd5@jasper>","date":"2024-03-26T11:03:54","subject":"Re: [PATCH 05/10] ipa: ipu3: Parse and store Agc stats","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:46PM +0000, Daniel Scally wrote:\n> In preparation for switching to a derivation of MeanLuminanceAgc, add\n> a function to parse and store the statistics for easy retrieval in an\n> overriding estimateLuminance() function.\n> \n> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/algorithms/agc.cpp | 33 +++++++++++++++++++++++++++++++++\n>  src/ipa/ipu3/algorithms/agc.h   |  8 ++++++++\n>  2 files changed, 41 insertions(+)\n> \n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index 606a237a..ee9a42cf 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -142,6 +142,39 @@ double Agc::measureBrightness(const ipu3_uapi_stats_3a *stats,\n>  \treturn Histogram(Span<uint32_t>(hist)).interQuantileMean(0.98, 1.0);\n>  }\n>  \n> +void Agc::parseStatistics(const ipu3_uapi_stats_3a *stats,\n> +\t\t\t  const ipu3_uapi_grid_config &grid)\n> +{\n> +\tuint32_t hist[knumHistogramBins] = { 0 };\n> +\n> +\treds_.clear();\n> +\tgreens_.clear();\n> +\tblues_.clear();\n> +\n> +\tfor (unsigned int cellY = 0; cellY < grid.height; cellY++) {\n> +\t\tfor (unsigned int cellX = 0; cellX < grid.width; cellX++) {\n> +\t\t\tuint32_t cellPosition = cellY * stride_ + cellX;\n> +\n> +\t\t\tconst ipu3_uapi_awb_set_item *cell =\n> +\t\t\t\treinterpret_cast<const ipu3_uapi_awb_set_item *>(\n> +\t\t\t\t\t&stats->awb_raw_buffer.meta_data[cellPosition]);\n> +\n> +\t\t\treds_.push_back(cell->R_avg);\n> +\t\t\tgreens_.push_back((cell->Gr_avg + cell->Gb_avg) / 2);\n> +\t\t\tblues_.push_back(cell->B_avg);\n> +\n> +\t\t\t/*\n> +\t\t\t * Store the average green value to estimate the\n> +\t\t\t * brightness. Even the overexposed pixels are\n> +\t\t\t * taken into account.\n> +\t\t\t */\n> +\t\t\thist[(cell->Gr_avg + cell->Gb_avg) / 2]++;\n\nWhy are only the greens taken into account?  Ahh its just a copy of\nexisting code, that gets removed in patch 7/10. Still should that be\nchanged to hist[r*0.299 + (gr + gb) / 2 * 0.587 + b * 0.114]++ ?\n\nOr am I missing something here?\n\n> +\t\t}\n> +\t}\n> +\n> +\thist_ = Histogram(Span<uint32_t>(hist));\n> +}\n> +\n>  /**\n>   * \\brief Apply a filter on the exposure value to limit the speed of changes\n>   * \\param[in] exposureValue The target exposure from the AGC algorithm\n> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n> index 9d6e3ff1..7ed0ef7a 100644\n> --- a/src/ipa/ipu3/algorithms/agc.h\n> +++ b/src/ipa/ipu3/algorithms/agc.h\n> @@ -13,6 +13,8 @@\n>  \n>  #include <libcamera/geometry.h>\n>  \n> +#include \"libipa/histogram.h\"\n> +\n>  #include \"algorithm.h\"\n>  \n>  namespace libcamera {\n> @@ -43,6 +45,8 @@ private:\n>  \t\t\t\t const ipu3_uapi_grid_config &grid,\n>  \t\t\t\t const ipu3_uapi_stats_3a *stats,\n>  \t\t\t\t double gain);\n> +\tvoid parseStatistics(const ipu3_uapi_stats_3a *stats,\n> +\t\t\t     const ipu3_uapi_grid_config &grid);\n>  \n>  \tuint64_t frameCount_;\n>  \n> @@ -55,6 +59,10 @@ private:\n>  \tutils::Duration filteredExposure_;\n>  \n>  \tuint32_t stride_;\n> +\tstd::vector<uint8_t> reds_;\n> +\tstd::vector<uint8_t> blues_;\n> +\tstd::vector<uint8_t> greens_;\n> +\tHistogram hist_;\n>  };\n>  \n>  } /* namespace ipa::ipu3::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 9D973C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Mar 2024 11:04:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 118B963311;\n\tTue, 26 Mar 2024 12:03:59 +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 9E6AF61C41\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Mar 2024 12:03:57 +0100 (CET)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:a916:1c71:357:e10c])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E9F62497;\n\tTue, 26 Mar 2024 12:03:25 +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=\"QGa/b3iM\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1711451006;\n\tbh=7kp54O/CxYYE89GlGoXbhL3iSJIqpwWWMJ8B47GKBFI=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=QGa/b3iMeAKOfGtaLXebtM3ZuIrJSzdM4vJC2XCAA0q4u0gyicJ9ortJGz5xcvBxN\n\tf6og9JnHlDkRdqdoocT4Uf19AAK+51wdwcU0iizqVxZDOW8VUi0GrpgoKnGYWSNc58\n\toALXZIRshSEv6dW9Z7XWzjoF+YR7KP18/eXRaww8=","Date":"Tue, 26 Mar 2024 12:03:54 +0100","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Daniel Scally <dan.scally@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 05/10] ipa: ipu3: Parse and store Agc stats","Message-ID":"<20240326110354.ul2mwfju6746tjd5@jasper>","References":"<20240322131451.3092931-1-dan.scally@ideasonboard.com>\n\t<20240322131451.3092931-6-dan.scally@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240322131451.3092931-6-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":29070,"web_url":"https://patchwork.libcamera.org/comment/29070/","msgid":"<53fc35cf-98a3-4656-8493-a12d3bed161f@ideasonboard.com>","date":"2024-03-26T12:39:33","subject":"Re: [PATCH 05/10] ipa: ipu3: Parse and store Agc stats","submitter":{"id":156,"url":"https://patchwork.libcamera.org/api/people/156/","name":"Dan Scally","email":"dan.scally@ideasonboard.com"},"content":"Hi Stefan\n\nOn 26/03/2024 11:03, Stefan Klug wrote:\n> Hi Daniel,\n>\n> Thanks for the patch.\n>\n> On Fri, Mar 22, 2024 at 01:14:46PM +0000, Daniel Scally wrote:\n>> In preparation for switching to a derivation of MeanLuminanceAgc, add\n>> a function to parse and store the statistics for easy retrieval in an\n>> overriding estimateLuminance() function.\n>>\n>> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n>> ---\n>>   src/ipa/ipu3/algorithms/agc.cpp | 33 +++++++++++++++++++++++++++++++++\n>>   src/ipa/ipu3/algorithms/agc.h   |  8 ++++++++\n>>   2 files changed, 41 insertions(+)\n>>\n>> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n>> index 606a237a..ee9a42cf 100644\n>> --- a/src/ipa/ipu3/algorithms/agc.cpp\n>> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n>> @@ -142,6 +142,39 @@ double Agc::measureBrightness(const ipu3_uapi_stats_3a *stats,\n>>   \treturn Histogram(Span<uint32_t>(hist)).interQuantileMean(0.98, 1.0);\n>>   }\n>>   \n>> +void Agc::parseStatistics(const ipu3_uapi_stats_3a *stats,\n>> +\t\t\t  const ipu3_uapi_grid_config &grid)\n>> +{\n>> +\tuint32_t hist[knumHistogramBins] = { 0 };\n>> +\n>> +\treds_.clear();\n>> +\tgreens_.clear();\n>> +\tblues_.clear();\n>> +\n>> +\tfor (unsigned int cellY = 0; cellY < grid.height; cellY++) {\n>> +\t\tfor (unsigned int cellX = 0; cellX < grid.width; cellX++) {\n>> +\t\t\tuint32_t cellPosition = cellY * stride_ + cellX;\n>> +\n>> +\t\t\tconst ipu3_uapi_awb_set_item *cell =\n>> +\t\t\t\treinterpret_cast<const ipu3_uapi_awb_set_item *>(\n>> +\t\t\t\t\t&stats->awb_raw_buffer.meta_data[cellPosition]);\n>> +\n>> +\t\t\treds_.push_back(cell->R_avg);\n>> +\t\t\tgreens_.push_back((cell->Gr_avg + cell->Gb_avg) / 2);\n>> +\t\t\tblues_.push_back(cell->B_avg);\n>> +\n>> +\t\t\t/*\n>> +\t\t\t * Store the average green value to estimate the\n>> +\t\t\t * brightness. Even the overexposed pixels are\n>> +\t\t\t * taken into account.\n>> +\t\t\t */\n>> +\t\t\thist[(cell->Gr_avg + cell->Gb_avg) / 2]++;\n> Why are only the greens taken into account?  Ahh its just a copy of\n> existing code, that gets removed in patch 7/10. Still should that be\n> changed to hist[r*0.299 + (gr + gb) / 2 * 0.587 + b * 0.114]++ ?\n>\n> Or am I missing something here?\n\n\nNo you're missing nothing; I think that that's the right thing to do but I wanted to keep this \nseries as closely as possible to the existing behaviour to make it easier to integrate. I can add a \npatch on top to switch this though?\n\n>\n>> +\t\t}\n>> +\t}\n>> +\n>> +\thist_ = Histogram(Span<uint32_t>(hist));\n>> +}\n>> +\n>>   /**\n>>    * \\brief Apply a filter on the exposure value to limit the speed of changes\n>>    * \\param[in] exposureValue The target exposure from the AGC algorithm\n>> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n>> index 9d6e3ff1..7ed0ef7a 100644\n>> --- a/src/ipa/ipu3/algorithms/agc.h\n>> +++ b/src/ipa/ipu3/algorithms/agc.h\n>> @@ -13,6 +13,8 @@\n>>   \n>>   #include <libcamera/geometry.h>\n>>   \n>> +#include \"libipa/histogram.h\"\n>> +\n>>   #include \"algorithm.h\"\n>>   \n>>   namespace libcamera {\n>> @@ -43,6 +45,8 @@ private:\n>>   \t\t\t\t const ipu3_uapi_grid_config &grid,\n>>   \t\t\t\t const ipu3_uapi_stats_3a *stats,\n>>   \t\t\t\t double gain);\n>> +\tvoid parseStatistics(const ipu3_uapi_stats_3a *stats,\n>> +\t\t\t     const ipu3_uapi_grid_config &grid);\n>>   \n>>   \tuint64_t frameCount_;\n>>   \n>> @@ -55,6 +59,10 @@ private:\n>>   \tutils::Duration filteredExposure_;\n>>   \n>>   \tuint32_t stride_;\n>> +\tstd::vector<uint8_t> reds_;\n>> +\tstd::vector<uint8_t> blues_;\n>> +\tstd::vector<uint8_t> greens_;\n>> +\tHistogram hist_;\n>>   };\n>>   \n>>   } /* namespace ipa::ipu3::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 0E1A4BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Mar 2024 12:39:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 415B263326;\n\tTue, 26 Mar 2024 13:39: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 93E4F63037\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 26 Mar 2024 13:39:36 +0100 (CET)","from [192.168.0.43]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B530363B;\n\tTue, 26 Mar 2024 13:39:04 +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=\"ZbLxSmj7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1711456744;\n\tbh=/Y3s0LEno+JU8aWnZM+sV79A5TcZoQ/Lc0gF307HNAs=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=ZbLxSmj7/g4/Glya3dVUvB3zEr9P2s/4jVFdUogPq+mrOnE66MuNDx/TKrNLGiABA\n\t0nUtbYcuK0aGTEeQlhMxZdnfY9szynVcD2Gysaid8oOyNNGLGb7aztMP4sMY5YU8Af\n\t+ruFCvabVWMpeVG8G5I4g8wcKouINdhz8IGAw6gA=","Message-ID":"<53fc35cf-98a3-4656-8493-a12d3bed161f@ideasonboard.com>","Date":"Tue, 26 Mar 2024 12:39:33 +0000","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 05/10] ipa: ipu3: Parse and store Agc stats","Content-Language":"en-US","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","References":"<20240322131451.3092931-1-dan.scally@ideasonboard.com>\n\t<20240322131451.3092931-6-dan.scally@ideasonboard.com>\n\t<20240326110354.ul2mwfju6746tjd5@jasper>","From":"Dan Scally <dan.scally@ideasonboard.com>","Autocrypt":"addr=dan.scally@ideasonboard.com; keydata=\n\txsFNBGLydlEBEADa5O2s0AbUguprfvXOQun/0a8y2Vk6BqkQALgeD6KnXSWwaoCULp18etYW\n\tB31bfgrdphXQ5kUQibB0ADK8DERB4wrzrUb5CMxLBFE7mQty+v5NsP0OFNK9XTaAOcmD+Ove\n\teIjYvqurAaro91jrRVrS1gBRxIFqyPgNvwwL+alMZhn3/2jU2uvBmuRrgnc/e9cHKiuT3Dtq\n\tMHGPKL2m+plk+7tjMoQFfexoQ1JKugHAjxAhJfrkXh6uS6rc01bYCyo7ybzg53m1HLFJdNGX\n\tsUKR+dQpBs3SY4s66tc1sREJqdYyTsSZf80HjIeJjU/hRunRo4NjRIJwhvnK1GyjOvvuCKVU\n\tRWpY8dNjNu5OeAfdrlvFJOxIE9M8JuYCQTMULqd1NuzbpFMjc9524U3Cngs589T7qUMPb1H1\n\tNTA81LmtJ6Y+IV5/kiTUANflpzBwhu18Ok7kGyCq2a2jsOcVmk8gZNs04gyjuj8JziYwwLbf\n\tvzABwpFVcS8aR+nHIZV1HtOzyw8CsL8OySc3K9y+Y0N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bqXe8RDuR\n\tdu90hvCJkq7/tzSQ0GeD3BwXb9/R/A4dVXhaDd91Q1qQXidI+2jwhx8iqiYxbT+DoAUkQRQy\n\txBtoCM1CxH7u45URUgD//fxYr3D4B1SlonA6vdaEdHZOGwECnDpTxecENMbz/Bx7qfrmd901\n\tD+N9SjIwrbVhhSyUXYnSUb8F+9g2RDY42Sk7GcYxIeON4VzKqWM7hpkXZ47pkK0YodO+dRKM\n\tyMcoUWrTK0Uz6UzUGKoJVbxmSW/EJLEGoI5p3NWxWtScEVv8mO49gqQdrRIOheZycDmHnItt\n\t9Qjv00uFhEwv2YfiyGk6iGF2W40s2pH2t6oeuGgmiZ7g6d0MEK8Ql/4zPItvr1c1rpwpXUC1\n\tu1kQWgtnNjFHX3KiYdqjcZeRBiry1X0zY+4Y24wUU0KsEewJwjhmCKAsju1RpdlPg2kC","In-Reply-To":"<20240326110354.ul2mwfju6746tjd5@jasper>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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":29166,"web_url":"https://patchwork.libcamera.org/comment/29166/","msgid":"<20240405233935.GA12903@pendragon.ideasonboard.com>","date":"2024-04-05T23:39:35","subject":"Re: [PATCH 05/10] ipa: ipu3: Parse and store Agc stats","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:46PM +0000, Daniel Scally wrote:\n> In preparation for switching to a derivation of MeanLuminanceAgc, add\n> a function to parse and store the statistics for easy retrieval in an\n> overriding estimateLuminance() function.\n\nThis is hard to review separately from 06/10, I would squash the two\npatches together.\n\n> Signed-off-by: Daniel Scally <dan.scally@ideasonboard.com>\n> ---\n>  src/ipa/ipu3/algorithms/agc.cpp | 33 +++++++++++++++++++++++++++++++++\n>  src/ipa/ipu3/algorithms/agc.h   |  8 ++++++++\n>  2 files changed, 41 insertions(+)\n> \n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index 606a237a..ee9a42cf 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -142,6 +142,39 @@ double Agc::measureBrightness(const ipu3_uapi_stats_3a *stats,\n>  \treturn Histogram(Span<uint32_t>(hist)).interQuantileMean(0.98, 1.0);\n>  }\n>  \n> +void Agc::parseStatistics(const ipu3_uapi_stats_3a *stats,\n> +\t\t\t  const ipu3_uapi_grid_config &grid)\n> +{\n> +\tuint32_t hist[knumHistogramBins] = { 0 };\n> +\n> +\treds_.clear();\n> +\tgreens_.clear();\n> +\tblues_.clear();\n> +\n> +\tfor (unsigned int cellY = 0; cellY < grid.height; cellY++) {\n> +\t\tfor (unsigned int cellX = 0; cellX < grid.width; cellX++) {\n> +\t\t\tuint32_t cellPosition = cellY * stride_ + cellX;\n> +\n> +\t\t\tconst ipu3_uapi_awb_set_item *cell =\n> +\t\t\t\treinterpret_cast<const ipu3_uapi_awb_set_item *>(\n> +\t\t\t\t\t&stats->awb_raw_buffer.meta_data[cellPosition]);\n> +\n> +\t\t\treds_.push_back(cell->R_avg);\n> +\t\t\tgreens_.push_back((cell->Gr_avg + cell->Gb_avg) / 2);\n> +\t\t\tblues_.push_back(cell->B_avg);\n> +\n> +\t\t\t/*\n> +\t\t\t * Store the average green value to estimate the\n> +\t\t\t * brightness. Even the overexposed pixels are\n> +\t\t\t * taken into account.\n> +\t\t\t */\n> +\t\t\thist[(cell->Gr_avg + cell->Gb_avg) / 2]++;\n> +\t\t}\n> +\t}\n> +\n> +\thist_ = Histogram(Span<uint32_t>(hist));\n> +}\n> +\n>  /**\n>   * \\brief Apply a filter on the exposure value to limit the speed of changes\n>   * \\param[in] exposureValue The target exposure from the AGC algorithm\n> diff --git a/src/ipa/ipu3/algorithms/agc.h b/src/ipa/ipu3/algorithms/agc.h\n> index 9d6e3ff1..7ed0ef7a 100644\n> --- a/src/ipa/ipu3/algorithms/agc.h\n> +++ b/src/ipa/ipu3/algorithms/agc.h\n> @@ -13,6 +13,8 @@\n>  \n>  #include <libcamera/geometry.h>\n>  \n> +#include \"libipa/histogram.h\"\n> +\n>  #include \"algorithm.h\"\n>  \n>  namespace libcamera {\n> @@ -43,6 +45,8 @@ private:\n>  \t\t\t\t const ipu3_uapi_grid_config &grid,\n>  \t\t\t\t const ipu3_uapi_stats_3a *stats,\n>  \t\t\t\t double gain);\n> +\tvoid parseStatistics(const ipu3_uapi_stats_3a *stats,\n> +\t\t\t     const ipu3_uapi_grid_config &grid);\n>  \n>  \tuint64_t frameCount_;\n>  \n> @@ -55,6 +59,10 @@ private:\n>  \tutils::Duration filteredExposure_;\n>  \n>  \tuint32_t stride_;\n> +\tstd::vector<uint8_t> reds_;\n> +\tstd::vector<uint8_t> blues_;\n> +\tstd::vector<uint8_t> greens_;\n> +\tHistogram hist_;\n>  };\n>  \n>  } /* namespace ipa::ipu3::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 D5B47C0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  5 Apr 2024 23:39:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6D3D36334D;\n\tSat,  6 Apr 2024 01:39:48 +0200 (CEST)","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 931F861C15\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  6 Apr 2024 01:39:46 +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 6D151231;\n\tSat,  6 Apr 2024 01:39:07 +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=\"r51maotP\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1712360347;\n\tbh=i62Ucg1O+QEVOn52WITlnMT2rid4ddNn09hcisI/i8w=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=r51maotPJNsBhpQGR8g8z4x1DUi3IsD3sbG2DGeecdQ5hRykMMGl/2VUyF1Hb21xd\n\tu+KAWGXl27poZ1AkQA2ePDhlF2e7brJ3AXCUSj+pJOfnSRl8FXpitQxwoJhBxtU5Hp\n\tdlMaODOUdnUNW2uYwktEZIVhiMYc7KVLrcfpu6Ao=","Date":"Sat, 6 Apr 2024 02:39:35 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Daniel Scally <dan.scally@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 05/10] ipa: ipu3: Parse and store Agc stats","Message-ID":"<20240405233935.GA12903@pendragon.ideasonboard.com>","References":"<20240322131451.3092931-1-dan.scally@ideasonboard.com>\n\t<20240322131451.3092931-6-dan.scally@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240322131451.3092931-6-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>"}}]