{"id":24830,"url":"https://patchwork.libcamera.org/api/1.1/patches/24830/?format=json","web_url":"https://patchwork.libcamera.org/patch/24830/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20251023115034.2207-4-david.plowman@raspberrypi.com>","date":"2025-10-23T11:49:15","name":"[v2,3/5] ipa: rpi: pisp: Use a floating region to get whole image Y statistics","commit_ref":"3bc722b5da0dd32fe848505958a644705a946ae7","pull_url":null,"state":"accepted","archived":false,"hash":"ba154e183584fc19b42cdac53848d0821a85148a","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/24830/mbox/","series":[{"id":5519,"url":"https://patchwork.libcamera.org/api/1.1/series/5519/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5519","date":"2025-10-23T11:49:12","name":"Fix and improve full image Y statistics","version":2,"mbox":"https://patchwork.libcamera.org/series/5519/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/24830/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/24830/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":["parsemail@patchwork.libcamera.org","kbingham@ideasonboard.com"],"Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id AFFBCBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 26 Oct 2025 23:32:02 +0000 (UTC)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net\n\t[86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 13F58AB4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 27 Oct 2025 00:30:15 +0100 (CET)","from perceval.ideasonboard.com\n\tby perceval.ideasonboard.com with LMTP id OK0VGTUW+mgSUhcA4E0KoQ\n\t(envelope-from <libcamera-devel-bounces@lists.libcamera.org>)\n\tfor <kbingham@ideasonboard.com>; Thu, 23 Oct 2025 13:49:09 +0200","from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\tby perceval.ideasonboard.com (Postfix) with ESMTPS\n\tid 1103E1AA6;\tThu, 23 Oct 2025 13:49:03 +0200 (CEST)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0BE7C607DB;\n\tThu, 23 Oct 2025 13:50:47 +0200 (CEST)","from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com\n\t[IPv6:2a00:1450:4864:20::42b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D87E4607D9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 13:50:42 +0200 (CEST)","by mail-wr1-x42b.google.com with SMTP id\n\tffacd0b85a97d-3ee64bc6b90so596154f8f.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Oct 2025 04:50:42 -0700 (PDT)","from davidp-pi.pitowers.org\n\t([2a00:1098:3142:1f:f75f:a9a5:3eb7:34d4]) by smtp.gmail.com with\n\tESMTPSA id\n\tffacd0b85a97d-4298b996aaasm1900760f8f.3.2025.10.23.04.50.41\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 23 Oct 2025 04:50:41 -0700 (PDT)"],"Authentication-Results":["perceval.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.a=rsa-sha256 header.s=google header.b=E72KPq++; \n\tdkim-atps=neutral","lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"E72KPq++\";\tdkim-atps=neutral"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1761220242; x=1761825042;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=i2AVjQETpTL9rS5lEaiFVmW3N5s72qqdEqXQEPC35yg=;\n\tb=E72KPq++0rE7gwL62Fts6J6UvQWan0C205Yt3/XfmWQy3YarPo6PEZ2bs37jY2NRJM\n\tI3ustot0UJbj9mY9IxZfkQokwPg/IQStJdJulHUrWpXmQn6bhT5CuFIsSINu9C/8Q+2q\n\txtCQVwNSEqPalsxf5PD/01nL4l2y9zS0+/Hjd+yCosBTWSJFPcWYD4dWF1iD6gkHRafo\n\tAqelM7faN9nVxBGZ2Cy+3Buf2EiCmtAc40mqXRESpyQz8teimy39fRdYCaS2OhY6Ezsz\n\tsmuPf4OQHnQGxyoS93yRMS2WFE1f2rhv5dFYNzkUnZpsDQ1yE7N79Qg2Gja0EGv7/86L\n\t79Gw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1761220242; x=1761825042;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=i2AVjQETpTL9rS5lEaiFVmW3N5s72qqdEqXQEPC35yg=;\n\tb=R8m8PHElI1T1oersVMT+1D6UBF/2mi72Zmp6M2Mr32cnptQDywHlliincPvVZ/TES0\n\tdgA3kKqI3cu7XAXVttOE1LdHLcXKUCDqGz3XH4kVTS7bEbsbDi1jMoVOSgnm8dKk4Oyt\n\tsDRhimeO2zabR+y9Dj3BYbJNzMNhdD0wcXxDl2PdJlWirO+dRC39tzzFya3TvIDhY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id\n\tffacd0b85a97d-42704d900a9mr16829375f8f.24.1761220241989; \n\tThu, 23 Oct 2025 04:50:41 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"David Plowman <david.plowman@raspberrypi.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>,\n\tNaushir Patuck <naush@raspberrypi.com>","Subject":"[PATCH v2 3/5] ipa: rpi: pisp: Use a floating region to get whole\n\timage Y statistics","Date":"Thu, 23 Oct 2025 12:49:15 +0100","Message-ID":"<20251023115034.2207-4-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.47.3","In-Reply-To":"<20251023115034.2207-1-david.plowman@raspberrypi.com>","References":"<20251023115034.2207-1-david.plowman@raspberrypi.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>","X-TUID":"t1/H0G7Fme3r","Resent-From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Resent-To":"parsemail@patchwork.libcamera.org"},"content":"Floating regions are currently unused on the PiSP platform, so we can\nuse one of them to get an average Y value for the whole image.\n\nIf an algorithm (such as the \"lux\" algorithm) wants a scene-referred\nestimate of absolute brightness, then this would be a better choice\nthan a value from Y histogram as the latter is not invariant to the\nmetering mode (e.g. centre-weighted, spot etc.). (So note that for the\nAGC/AEC algorithm, where the metering mode is relevant, the Y\nhistogram is the appropriate choice.)\n\nWe also fix the loop that copies the hardware's floating region values\ninto our statistics structure; it was using the wrong limit which was\ncausing it not to do anything.\n\nA future commit will update the lux algorithm to use this feature.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/rpi/pisp/pisp.cpp | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)","diff":"diff --git a/src/ipa/rpi/pisp/pisp.cpp b/src/ipa/rpi/pisp/pisp.cpp\nindex 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 \t/* AGC region sums only get collected on floating zones. */\n \tstatistics->agcRegions.init({ 0, 0 }, PISP_FLOATING_STATS_NUM_ZONES);\n-\tfor (i = 0; i < statistics->agcRegions.numRegions(); i++)\n+\tfor (i = 0; i < PISP_FLOATING_STATS_NUM_ZONES; i++)\n \t\tstatistics->agcRegions.setFloating(i,\n \t\t\t\t\t\t   { { 0, 0, 0, stats->agc.floating[i].Y_sum },\n \t\t\t\t\t\t     stats->agc.floating[i].counted, 0 });\n@@ -985,6 +985,12 @@ void IpaPiSP::setStatsAndDebin()\n \t */\n \tsetHistogramWeights();\n \n+\t/* Configure the first AGC floating region to cover the whole image, for the lux algo. */\n+\tpisp_fe_floating_stats_config floatingStatsConfig = {};\n+\tfloatingStatsConfig.regions[0].size_x = mode_.width;\n+\tfloatingStatsConfig.regions[0].size_y = mode_.height;\n+\tfe_->SetFloatingStats(floatingStatsConfig);\n+\n \tpisp_be_global_config beGlobal;\n \tbe_->GetGlobal(beGlobal);\n \n","prefixes":["v2","3/5"]}