[{"id":36355,"web_url":"https://patchwork.libcamera.org/comment/36355/","msgid":"<176095422952.336133.18242548197143327273@localhost>","date":"2025-10-20T09:57:09","subject":"Re: [PATCH 3/5] ipa: rpi: pisp: Use a floating region to get whole\n\timage Y statistics","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi David,\n\nQuoting David Plowman (2025-10-17 12:05:39)\n> Floating regions are currently unused on the PiSP platform, so we can\n> use one of them to get an average Y value for the whole image.\n> \n> If an algorithm (such as the \"lux\" algorithm) wants a scene-referred\n> estimate of absolute brightness, then this would be a better choice\n> than a value from Y histogram as the latter is not invariant to the\n> metering mode (e.g. centre-weighted, spot etc.). (So note that for the\n> AGC/AEC algorithm, where the metering mode is relevant, the Y\n> histogram is the appropriate choice.)\n> \n> We also fix the loop that copies the hardware's floating region values\n> into our statistics structure; it was using the wrong limit which was\n> causing it not to do anything.\n> \n> A future commit will update the lux algorithm to use this feature.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n\nI can't really comment on the hardware details. But it looks good to me\n:-)\n\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com> \n\nCheers,\nStefan\n\n> ---\n>  src/ipa/rpi/pisp/pisp.cpp | 8 +++++++-\n>  1 file changed, 7 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/ipa/rpi/pisp/pisp.cpp b/src/ipa/rpi/pisp/pisp.cpp\n> index bb50a9e0..2ba879c1 100644\n> --- a/src/ipa/rpi/pisp/pisp.cpp\n> +++ b/src/ipa/rpi/pisp/pisp.cpp\n> @@ -467,7 +467,7 @@ RPiController::StatisticsPtr IpaPiSP::platformProcessStats(Span<uint8_t> mem)\n>  \n>         /* AGC region sums only get collected on floating zones. */\n>         statistics->agcRegions.init({ 0, 0 }, PISP_FLOATING_STATS_NUM_ZONES);\n> -       for (i = 0; i < statistics->agcRegions.numRegions(); i++)\n> +       for (i = 0; i < PISP_FLOATING_STATS_NUM_ZONES; i++)\n>                 statistics->agcRegions.setFloating(i,\n>                                                    { { 0, 0, 0, stats->agc.floating[i].Y_sum },\n>                                                      stats->agc.floating[i].counted, 0 });\n> @@ -985,6 +985,12 @@ void IpaPiSP::setStatsAndDebin()\n>          */\n>         setHistogramWeights();\n>  \n> +       /* Configure the first AGC floating region to cover the whole image, for the lux algo. */\n> +       pisp_fe_floating_stats_config floatingStatsConfig = {};\n> +       floatingStatsConfig.regions[0].size_x = mode_.width;\n> +       floatingStatsConfig.regions[0].size_y = mode_.height;\n> +       fe_->SetFloatingStats(floatingStatsConfig);\n> +\n>         pisp_be_global_config beGlobal;\n>         be_->GetGlobal(beGlobal);\n>  \n> -- \n> 2.47.3\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 079AABE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Oct 2025 09:57:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 26A5A60705;\n\tMon, 20 Oct 2025 11:57:14 +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 B8B7A606FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 Oct 2025 11:57:12 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:9f50:5b33:d3ec:e1ea])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id 97D66F52;\n\tMon, 20 Oct 2025 11:55:29 +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=\"XcKy+zAi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1760954129;\n\tbh=Sfg9fc8tNRibbQDkd7RY03zptcnW2kf4LsGZMIQXfn0=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=XcKy+zAiNvojSkO1GOY3WQseTaZ3wEhs6KzNGaqshV3GNbLv09d0S3zpqJZJRZDMo\n\t3I6rLiitxEFKqCTn7IegiNyqkxN275WmOYWqwUrG2CF4r8Bx1Inqi99enlLTT3Y6zN\n\tLtTSGa0M8+HOmInv8BCEPbbQr5K2ZCYqQnSLX3m4=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251017102704.3887-4-david.plowman@raspberrypi.com>","References":"<20251017102704.3887-1-david.plowman@raspberrypi.com>\n\t<20251017102704.3887-4-david.plowman@raspberrypi.com>","Subject":"Re: [PATCH 3/5] ipa: rpi: pisp: Use a floating region to get whole\n\timage Y statistics","From":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"David Plowman <david.plowman@raspberrypi.com>","To":"David Plowman <david.plowman@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 20 Oct 2025 11:57:09 +0200","Message-ID":"<176095422952.336133.18242548197143327273@localhost>","User-Agent":"alot/0.12.dev8+g2c003385c862.d20250602","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":36397,"web_url":"https://patchwork.libcamera.org/comment/36397/","msgid":"<CAEmqJPqBgjP6EWYeq9-GTdUbtibOpL1C4d+ZTW-ySH-Q1OobLQ@mail.gmail.com>","date":"2025-10-23T07:38:26","subject":"Re: [PATCH 3/5] ipa: rpi: pisp: Use a floating region to get whole\n\timage Y statistics","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi David,\n\nOn Fri, 17 Oct 2025 at 11:27, David Plowman <david.plowman@raspberrypi.com>\nwrote:\n\n> Floating regions are currently unused on the PiSP platform, so we can\n> use one of them to get an average Y value for the whole image.\n>\n> If an algorithm (such as the \"lux\" algorithm) wants a scene-referred\n> estimate of absolute brightness, then this would be a better choice\n> than a value from Y histogram as the latter is not invariant to the\n> metering mode (e.g. centre-weighted, spot etc.). (So note that for the\n> AGC/AEC algorithm, where the metering mode is relevant, the Y\n> histogram is the appropriate choice.)\n>\n> We also fix the loop that copies the hardware's floating region values\n> into our statistics structure; it was using the wrong limit which was\n> causing it not to do anything.\n>\n> A future commit will update the lux algorithm to use this feature.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n>\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n\n> ---\n>  src/ipa/rpi/pisp/pisp.cpp | 8 +++++++-\n>  1 file changed, 7 insertions(+), 1 deletion(-)\n>\n> diff --git a/src/ipa/rpi/pisp/pisp.cpp b/src/ipa/rpi/pisp/pisp.cpp\n> index bb50a9e0..2ba879c1 100644\n> --- a/src/ipa/rpi/pisp/pisp.cpp\n> +++ b/src/ipa/rpi/pisp/pisp.cpp\n> @@ -467,7 +467,7 @@ RPiController::StatisticsPtr\n> IpaPiSP::platformProcessStats(Span<uint8_t> mem)\n>\n>         /* AGC region sums only get collected on floating zones. */\n>         statistics->agcRegions.init({ 0, 0 },\n> PISP_FLOATING_STATS_NUM_ZONES);\n> -       for (i = 0; i < statistics->agcRegions.numRegions(); i++)\n> +       for (i = 0; i < PISP_FLOATING_STATS_NUM_ZONES; i++)\n>                 statistics->agcRegions.setFloating(i,\n>                                                    { { 0, 0, 0,\n> stats->agc.floating[i].Y_sum },\n>\n>  stats->agc.floating[i].counted, 0 });\n> @@ -985,6 +985,12 @@ void IpaPiSP::setStatsAndDebin()\n>          */\n>         setHistogramWeights();\n>\n> +       /* Configure the first AGC floating region to cover the whole\n> image, for the lux algo. */\n> +       pisp_fe_floating_stats_config floatingStatsConfig = {};\n> +       floatingStatsConfig.regions[0].size_x = mode_.width;\n> +       floatingStatsConfig.regions[0].size_y = mode_.height;\n> +       fe_->SetFloatingStats(floatingStatsConfig);\n> +\n>         pisp_be_global_config beGlobal;\n>         be_->GetGlobal(beGlobal);\n>\n> --\n> 2.47.3\n>\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 65CDCBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 23 Oct 2025 07:39:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6F261607A8;\n\tThu, 23 Oct 2025 09:39:06 +0200 (CEST)","from mail-vs1-xe2c.google.com (mail-vs1-xe2c.google.com\n\t[IPv6:2607:f8b0:4864:20::e2c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CD67760763\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 09:39:03 +0200 (CEST)","by mail-vs1-xe2c.google.com with SMTP id\n\tada2fe7eead31-5db284d46beso25199137.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 00:39:03 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"CXL8aztS\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1761205142; x=1761809942;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=SGxGyxDMQZCxsTj5V3KxF10eokZh61rbElr3n/GhL/Y=;\n\tb=CXL8aztSRyYqRpPYc7BP+qINYc9cvCxNHuXz5EDp/XBsnh2bYy4gK/z0okIdQ8Bq/a\n\tDaqn1hp3A0gYBG75hyk1UbaZhPxJ6E6ym7DA+vOICtbuFO8NPktGsH/ugZTKEf7Wx2sR\n\tzHeO/F74bV4Jubm5vLOC+8+vfCDnEjXsITFpwntQ5s7Xq1ruvdQ2ncaTeOv2ynWE4IDZ\n\trQBuFkqvbtCQe8K3QC15cPs3LdSIjoeMLa6uhhoy/SV8EFk4WHekGcZBnMNic6p67w34\n\tFl3moa+xNhkKdF1kdybead3JwoscyVvTEREQnbWFL5dCXXQgTHSzsqCDya1AFm9lkMza\n\tLMbA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1761205142; x=1761809942;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=SGxGyxDMQZCxsTj5V3KxF10eokZh61rbElr3n/GhL/Y=;\n\tb=AjLsEXoPoFV0U2yLN+UlUL6fHk/hdAtvoK201MfY7b/xCIaCiAwR6r9zpPs2+PemNp\n\tMrwP9OUxHHZ8pozl7/2W/+rXKQMacIqsayL5yEBuzRA+ciJtsa5DOhLMu0dIyuetRRVN\n\tU/xgoRSR0lq51onRG+E9RMTRRmiBtOhXzqsdlqWex4SWqSIzSQ2WoAi9QbGs/dJQjL14\n\t5G6PpxdIybpf7Z7osDN/r+lXcglATiko7p2qb7XZkchjNI3qO1zko3vxnGFn/2jSi2PO\n\thWcii8NRPyqldNQ2WRd7IAIIrcVv6vIj8ToiQMmwynO8TdXgPk7+Wlq7KH9LCdIE6QFM\n\t8ziA==","X-Gm-Message-State":"AOJu0Ywks+/259nGY7mcT32KCzSya0eaPm5HNauh1kuxmnDU2bvux3Bb\n\tGy6Gu32BZJvZv+bEupAr2whpnYYErmgoxqA6KlWmrPVKyjwbsrJkE496Q8xSUhESpA4jYF35xFK\n\tMFRVOsflRNXJvd5yWnkHVZ7Yxr0QM8WprcOlkkR5XieANy7/sRov1m/o=","X-Gm-Gg":"ASbGncsKVgxeCQ+mxFq8O43nwCgtRgxa75/0fSWuMw3icx7j9b/tah3WGLhc2mofjMq\n\tVa/zC3iAJQfyjtO+vU7BJJtfEsN1SJS0d/yGwqciDjijCn+88auo/I7UIM0Qf07azToopXPh/s0\n\tkAcWoDC4B8x9yMR01b3j33+ERcQGddp8ga40Cm69oay5L1RhTTTiSGog6WbkOw2/er0Hk/pQb9r\n\t+coV2aRguiVOSXz/lH6Kgg/CNrjCJb5dfejrzPYbaQ+hbz4C8sIAxQqUS8WLIfZORhDPuCBkvKa\n\tkCGrtdvQhR2CsQk=","X-Google-Smtp-Source":"AGHT+IHQE9KPRvTTb1kZu98jl7uCK2DirozNN6nsTOjxQ7Q23W2HqubSB8s4EREAG9C650/5e3E1s0krI6KU5+jw36c=","X-Received":"by 2002:a05:6102:1453:20b0:5db:3330:4be9 with SMTP id\n\tada2fe7eead31-5db33305624mr50406137.3.1761205142663; Thu, 23 Oct 2025\n\t00:39:02 -0700 (PDT)","MIME-Version":"1.0","References":"<20251017102704.3887-1-david.plowman@raspberrypi.com>\n\t<20251017102704.3887-4-david.plowman@raspberrypi.com>","In-Reply-To":"<20251017102704.3887-4-david.plowman@raspberrypi.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Thu, 23 Oct 2025 08:38:26 +0100","X-Gm-Features":"AWmQ_blzfPOd5UTIed14E2SXx4WECM0gssDAgv9KUNdtmKDSGxv-ZVJyfiNai6I","Message-ID":"<CAEmqJPqBgjP6EWYeq9-GTdUbtibOpL1C4d+ZTW-ySH-Q1OobLQ@mail.gmail.com>","Subject":"Re: [PATCH 3/5] ipa: rpi: pisp: Use a floating region to get whole\n\timage Y statistics","To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"multipart/alternative; boundary=\"000000000000e7c3670641ce86dd\"","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>"}}]